使用谷歌jmaps创建标记的实例参考下面:
var baseIcon = new GIcon();
51 baseIcon.shadow = "http://www.google.com/mapfiles/shadow50.png";
52 baseIcon.iconSize = new GSize(20, 34);
53 baseIcon.shadowSize = new GSize(37, 34);
54 baseIcon.iconAnchor = new GPoint(9, 34);
55 baseIcon.infoWindowAnchor = new GPoint(9, 2);
56 baseIcon.infoShadowAnchor = new GPoint(18, 25);
57
58 var pointIcon = new GIcon();
59 pointIcon.shadow = "http://www.google.com/mapfiles/arrowshadow.png";
60 pointIcon.iconSize = new GSize(39, 34);
61 pointIcon.shadowSize = new GSize(37, 34);
62 pointIcon.iconAnchor = new GPoint(9, 34);
63 pointIcon.infoWindowAnchor = new GPoint(9, 2);
64 pointIcon.infoShadowAnchor = new GPoint(18, 25);
65
66 function createArrow(point,text) {
67 var icon = new GIcon(pointIcon);
68 icon.image = "http://www.google.com/mapfiles/arrow.png";
69 var marker = new GMarker(point,icon);
70 GEvent.addListener(marker,"click", function() {
71 marker.openInfoWindowHtml(text);
72 });
73 return marker;
74 }
75 function createMarker(point, index, text) {
76 var letter = String.fromCharCode("A".charCodeAt(0) + index);
77 var icon = new GIcon(baseIcon);
78 icon.image = "http://www.google.com/mapfiles/marker" + letter + ".png";
79 var marker = new GMarker(point, icon);
80
81 GEvent.addListener(marker, "click", function() {
82 marker.openInfoWindowHtml(text);
83 });
84 return marker;
85 }
86 function toggle(id) {
87 var elem = document.getElementById(id);
88 if(elem != null) {
89 if (elem.style.display == 'none') {
90 elem.style.display = '';
91 } else {
92 elem.style.display = 'none';
93 }
94 }
95 }
jMaps由于在setCenter上有Bug,始终无法在使用过程中放大地图,放弃,下面为曾用到的代码:
//将地图设置为该市为中心,并放大
// jQuery('#map').jmap('SearchAddress', {
// 'query': $(this).text(),
// 'returnType': 'getLocations'
// }, function(result, options) {
// var valid = Mapifies.SearchCode(result.Status.code);
// if (valid.success) {
// jQuery.each(result.Placemark, function(i, point) {
// jQuery('#map').jmap('MoveTo', { centerMethod: 'pan', 'mapType': map, 'mapCenter': [point.Point.coordinates[1], point.Point.coordinates[0]], 'mapZoom': 11 });//
// });
// } else {
// jQuery('#address').val(valid.message);
// }
// });