Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>There are a couple of ways to do this, assuming you're using the latest version of Google Maps API. You could either<br> a) build a kml file that contains the points and/or shapes you need and display that on the map<br> b) iterate through your list of locations (gas stations) and use the marker manager to add individual pins to the map. </p> <p>Either solution is going to work pretty well and it really just depends on what you prefer to do. I would say that it is probably easier to go with option B and just get a JSON formatted array of locations from the server and use the marker manager to display them on the map. You can then display additional markup or redirect when a marker is clicked.</p> <p>Your JSON array could be as simple as: </p> <pre><code>[ {title:'Station A', latitude: 38.91912, longitude: 7.123121}, {title:'Station B', latitude: 34.81291, longitude: 30.87173}, {title:'Station C', latitude: 31.00123, longitude: 13.184918} ] </code></pre> <p>Here is a link to the MarkerManager script root (<a href="http://google-maps-utility-library-v3.googlecode.com/svn/trunk/markermanager/" rel="nofollow">http://google-maps-utility-library-v3.googlecode.com/svn/trunk/markermanager/</a>). Check out the examples folder for a few quick examples. The docs folder has some details but those pages don't seem to render properly for me at the moment.</p> <p>To show a KML layer using the maps API you'll need your target KML layer to be accessible by google's server (i.e. hosted on a public server). After that this code should get you in the ballpark:</p> <pre><code>var map; // Reference to your map object you created with 'new google.maps.Map()' var url = http://url.to/your.kml; var kml = new google.maps.KmlLayer(url); kml.setMap(map); </code></pre> <p>To remove the layer just use this code (assuming kml variable is a reference to the KmlLayer you created above):</p> <pre><code>kml.setMap(null); </code></pre> <p>Here is a link to the KmlLayer class in the Google Maps API documention: <a href="https://developers.google.com/maps/documentation/javascript/reference?hl=fr#KmlLayer" rel="nofollow">https://developers.google.com/maps/documentation/javascript/reference?hl=fr#KmlLayer</a></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload