cmabill Posted January 11, 2013 Share Posted January 11, 2013 how to insert google map on website I want to use below code for my google map, which is posted on internet and easy to understand, but it doesn't works. I hae get API key but when I replace the original key, I don't know which part of code I need to modified. how to get a GLatlng cooridinates cooresponding with my API key. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR...tml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8"/> <title>Google Maps Javascript API Example</title> <script src="http://maps.google.c...v=2&key=abcdefg" type="text/javascript"></script> <script type="text/javascript"> //<![CDATA[ function load() { if (GBrowserIsCompatible()) { var map = new GMap2(document.getElementById("map")); map.setCenter(new GLatLng(37.4419, -122.1419), 13); } } //]]> </script> </head> <body onload="load()" onunload="GUnload()"> <div id="map" style="width: 500px; height: 300px"></div> </body> </html> I think I only need to replace this two parts in red color, is there any more place that I should modified. I think this is the simple way that I could use google map on my website. pls come up with better ways if you could. thanks. Quote Link to comment https://forums.phpfreaks.com/topic/272995-how-to-make-a-google-map-on-my-website/ Share on other sites More sharing options...
haku Posted January 11, 2013 Share Posted January 11, 2013 That is the old, deprecated google maps API, version 2. The current version is version 3. You should find another tutorial that uses V3, or find a site that generates the code for you. Quote Link to comment https://forums.phpfreaks.com/topic/272995-how-to-make-a-google-map-on-my-website/#findComment-1404875 Share on other sites More sharing options...
cmabill Posted January 11, 2013 Author Share Posted January 11, 2013 thank you Haku, I noticed this that when the map uploaded, I was reminded that my API key is not valid, and this is a map for V2, it's highly appreciated if you could give a link with simple map like v2. thank you again. Quote Link to comment https://forums.phpfreaks.com/topic/272995-how-to-make-a-google-map-on-my-website/#findComment-1404916 Share on other sites More sharing options...
cmabill Posted January 11, 2013 Author Share Posted January 11, 2013 anyone help me identify this code is for V2 or V3. <!DOCTYPE html> <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> <script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?key=YOUR_API_KEY&sensor=SET_TO_TRUE_OR_FALSE"> </script> <script type="text/javascript"> function initialize() { var mapOptions = { center: new google.maps.LatLng(-34.397, 150.644), zoom: 8, mapTypeId: google.maps.MapTypeId.ROADMAP }; var map = new google.maps.Map(document.getElementById("map_canvas"), mapOptions); } </script> </head> <body onload="initialize()"> <div id="map_canvas" style="width:100%; height:100%"></div> </body> </html> here is the link from google thank you for your help. Quote Link to comment https://forums.phpfreaks.com/topic/272995-how-to-make-a-google-map-on-my-website/#findComment-1404926 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.