Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
- <html>
- <head>
- <meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
- <style type="text/css">
- html { height: 100% }
- body { height: 100%; margin: 0; padding: 0 }
- #map-canvas { height: 100% }
- </style>
- <!-- Acquire your google maps API Key https://developers.google.com/maps/documentation/javascript/tutorial -->
- <script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?key=AIzaSyDPahUaopfWbadpOpOLolZuPX-pX129kF4&sensor=true">
- </script>
- <script type="text/javascript">
- //<![CDATA[
- var map;
- function loadMapJSON(json)
- {
- for (var i = 0; i < json.feed.entry.length; i++) {
- var entry = json.feed.entry[i];
- if(entry["gsx$name"].$t) {
- var lat = parseFloat(entry["gsx$latitude"].$t);
- var lng = parseFloat(entry["gsx$longitude"].$t);
- var myLatlng = new google.maps.LatLng(lat,lng);
- var label = entry["gsx$name"].$t;
- var marker = new google.maps.Marker({
- position: myLatlng,
- map: map,
- title: label
- });
- }
- }
- }
- function m_getJSON() {
- var mapOptions = {
- center: new google.maps.LatLng(30, 10),
- zoom: 2,
- mapTypeId: google.maps.MapTypeId.ROADMAP
- };
- map = new google.maps.Map(document.getElementById("map-canvas"),mapOptions);
- // Retrieve the JSON feed.
- var script = document.createElement('script');
- // The spreadsheet should be formatted like this :
- //https://docs.google.com/spreadsheet/ccc?key=0AvR75gIJvkFUdEtMSDJnY0tTN0Z0WXlhZDdhLUdJM2c&usp=drive_web#gid=0
- //Acquire this URL from the Google spreadsheet by looking at File->Publish to Web->Get A Link to
- //Published Data-> Choose ATOM and copy link and replace below up and add ?alt=json-in-script&ndplr=1&//callback=loadMapJSON on the end
- script.setAttribute('src', 'https://spreadsheets.google.com/feeds/list/0AvR75gIJvkFUdEtMSDJnY0tTN0Z0WXlhZDdhLUdJM2c/od6/public/values?alt=json-in-script&ndplr=1&callback=loadMapJSON');
- script.setAttribute('id', 'jsonScript');
- script.setAttribute('type', 'text/javascript');
- document.documentElement.firstChild.appendChild(script);
- }
- google.maps.event.addDomListener(window, 'load', m_getJSON);
- //]]>
- </script>
- </head>
- <body>
- <div id="map-canvas"/>
- </body>
- </html>
Add Comment
Please, Sign In to add comment