The easiest way to use Google Maps on your own web page is to:
1. First register the Google API key in http://code.google.com/intl/zh-CN/apis/maps/.
2. Copy the following code to your page:
<script src= "http://ditu.google.com/maps?file=api&v=2&key=abqiaaaacegf_- 3GOIYVTZKJQXPFORQLLSS0KIFCGQZPJPLFE6GSGILJ3XSJGOVPJOISC69P5BCP8PUPWZK9OW&HL=ZH-CN "type=" Text/javascript " ></script> <!--Red is the Google API key-- <script type= "Text/javascript" > Function Initialize () { if (gbrowseriscompatible ()) { var map = new GMap2 (document.getElementById ("Map_canvas")); Map.setcenter (New Glatlng (22.556311, 113.936252), 14); Coordinate values Map.enablescrollwheelzoom ();//Allow rollers Map.addmaptype (G_PHYSICAL_MAP);//Add Terrain options Map.addcontrol (New Glargemapcontrol ()); Map.addcontrol (New Gmaptypecontrol ()); var point = new Glatlng (22.556338, 113.936186); Map.addoverlay (New Gmarker (point)); } } </script> <div id= "Map_canvas" style= "WIDTH:599PX; height:362px "></div> <script type= "Text/javascript" > Initialize (); </script> |
3. Find the coordinates of the location you need from the other operational maps and fill in the
map.setCenter(new GLatLng(x, y)...
location (can be found on Google Earth).
As the above code corresponds to the location of Shenzhen Nanshan Science Park north of the Han laser near.
How to use Google Maps in your own web pages