Now there are a lot of map JS available. I will start the content of this article in the form of Q & A. Finally, I will use a sample of georss + Google map API for V3.
1. Why should I select Google for the map API?
Free of charge. This may be the main consideration of many users. For small and medium-sized enterprises, this is the case.
2. Why V3?
Because V2 needs to register a Google account and apply for a key. but it is not required in V3. the design concept of V3 is better than v2, but most of the applications seen on the market are examples or books of V2. kml and XML files can be introduced in V3 to reduce the amount of code. it can be said that no developer can find a V3 example.
3. Are there major changes from V2 to V3?
Not big. because GIS applications have been developed for many years. besides, Google is not the first company to provide the map service. some concepts of GIS applications will not change. however, some nouns are changed to objects. let's look at the basic map object. gmap2 in V2 and Google in V3. maps. map. some basic objects are listed below.
Marker V2 gmarker
V3 Google. Maps. Marker
Weft longitude V2 glatlng
V3 Google. Maps. latlng
Information Window V2 ginfowindow
V3 Google. Maps. infowindow
Register event V2 gevent. addlistener
V3 Google. Maps. event. addlistener
Introduce JS file V2 http://ditu.google.cn/maps? File = API & amp; V = 2.x& amp; Key = ABQIAAAAzr2EBOXUKnm_jVnk0OJI7xSosDVG8KKPE1-m51RBrvYughuyMxQ-i1QfUnH94QxWIa6N4U6MouMmBA & HL = ZH-CN
V3 http://maps.google.com/maps/api/js? Sensor = true
4. The following is an example of an atom + georss application.
First, it takes some time to change the XML file to see the content. to put it bluntly, Google map API loading XML and reading nodes are not real-time. I suggest you put the XML file in sitemap. XML and submit it to Google. I have not found how to customize the icon of marker in this example. if you find the answer and want to tell me, mail: xiaofanku@gmail.com. thank you very much
Second, if you debug locally, it is not recommended to FTP the XML file to the folder specified by the public network.
Code:
JS Code will not be pasted. You can find it in the V3 example. What I want you to see is the XML structure.
<? XML version = "1.0" encoding = "UTF-8"?> <Feed xmlns = "http://www.w3.org/2005/Atom" xmlns: georss = "http://www.georss.org/georss"> <entry> <title> Sanshui International Business </title> <summary> No. 75, North Road, Zhizhi district, Yantai City, Shandong Province </Summary> <georss: point> 37.547592 121.381067 </georss: point> </entry> <title> sunshine 100 </title> <summary> No. 26, harbour Road, Zhizhi district, Yantai City, Shandong Province </Summary> <georss: point> 37.543037 121.385529 </georss: point> </entry> <title> 1st Avenue </title> <summary> No. 28, xisheng Street, Zhizhi district, Yantai City, Shandong Province </Summary> <georss: point> 37.543598 121.375885 </georss: point> </entry> </feed>
I would like to say a few more here. if you are proficient in XML, which of the following texts may be redundant to you. you only need to find the URLs of atom and georss. this is the end of the article. if you do not understand this XML file, continue reading it!
This XML file uses two namespaces. one is atom and the other is georss. only one element under the georss namespace is used in the file. <georss: point> the number of the subnode of the element. The first is the Latitude plus space plus the longitude. in fact, Google map API only cares about this node. if you do not have <summary >,< content >,< title> elements. all elements except the <georss: point> element belong to the element under the default atom namespace. when you open the XML file in your browser, you cannot see the content of the <georss: point> element. <entry> subnode: <title> is the infowindow title displayed when you click a marker. <summary> and <title> are added to the content of infowindow. you can use the <content type = "html"> element if you want to see pleasing content in infowindow. it can contain html dom nodes. if you want to see the final result of this example. you can create an HTML file locally to load the following georss XML file.
Http://luhuo.net20.net721.net/demo.xml
You can see. of course, you need to go to the reference address to find the JS Code. I cannot guarantee that the above XML address is still valid. the last is the reference address of atom, georss, and Google map API V3.
Atom: http://tools.ietf.org/html/rfc4287
Georss: http://www.georss.org/
Google map API v3: http://code.google.com/intl/zh-CN/apis/maps/documentation/javascript/basics.html