如何使用ajax在谷歌地图上设置标记?

时间:2016-09-05 10:08:17

标签: javascript jquery google-maps

我需要使用ajax调用在谷歌地图中动态设置标记。 怎么可能

我需要代码。

我想要ajax调用来更新谷歌地图。

使用ajax

动态更新标记
  var locations = [['spain',-41.054502,160.136719,'Uk',35.666222 ,39.019184],['china',58.025555,87.714844,'United Stat',35.666222 ,-44.472656],['Hong Kong',62.057586,44.121094,'United Stat',12.801088,18.457031],['Hong Kong',40.4523,102.128906,'United Stat',35.666222 ,-70.472656],['Hong Kong',28.526622,-76.816406,'United Stat',35.666222 ,-65.472656],['Hong Kong',28.526622,-76.816406,'United Stat',35.666222 ,-40.472656],['Hong Kong',28.526622,-45.816406,'United Stat',35.666222 ,-44.472656],['Hong Kong',28.526622,-24.816406,'United Stat',35.666222 ,-44.472656],['Hong Kong',28.526622,-76.816406,'United Stat',35.666222 ,-44.472656],['Hong Kong',28.526622,-76.816406,'United Stat',35.666222 ,-44.472656]]; 
function initialize() { 
var styledMapType = new google.maps.StyledMapType( 
[ 
{ 
"featureType": "all", 
"elementType": "labels.text.fill", 
"stylers": [ 
{ 
"saturation": 36 
}, 
{ 
"color": "#ffffff" 
}, 
{ 
"lightness": 40 
} 
] 
}, 
{ 
"featureType": "all", 
"elementType": "labels.text.stroke", 
"stylers": [ 
{ 
"visibility": "on" 
}, 
{ 
"color": "#000000" 
}, 
{ 
"lightness": 16 
} 
] 
}, 
{ 
"featureType": "all", 
"elementType": "labels.icon", 
"stylers": [ 
{ 
"visibility": "off" 
} 
] 
}, 
{ 
"featureType": "administrative", 
"elementType": "geometry.fill", 
"stylers": [ 
{ 
"color": "#ffffff" 
}, 
{ 
"lightness": 20 
} 
] 
}, 
{ 
"featureType": "administrative", 
"elementType": "geometry.stroke", 
"stylers": [ 
{ 
"color": "#ffffff" 
}, 
{ 
"lightness": 17 
}, 
{ 
"weight": 1.2 
} 
] 
}, 
{ 
"featureType": "landscape", 
"elementType": "geometry", 
"stylers": [ 
{ 
"color": "#000000" 
}, 
{ 
"lightness": 20 
} 
] 
}, 
{ 
"featureType": "poi", 
"elementType": "geometry", 
"stylers": [ 
{ 
"color": "#ffffff" 
}, 
{ 
"lightness": 21 
} 
] 
}, 
{ 
"featureType": "road.highway", 
"elementType": "geometry.fill", 
"stylers": [ 
{ 
"color": "#000000" 
}, 
{ 
"lightness": 17 
} 
] 
}, 
{ 
"featureType": "road.highway", 
"elementType": "geometry.stroke", 
"stylers": [ 
{ 
"color": "#000000" 
}, 
{ 
"lightness": 29 
}, 
{ 
"weight": 0.2 
} 
] 
}, 
{ 
"featureType": "road.arterial", 
"elementType": "geometry", 
"stylers": [ 
{ 
"color": "#000000" 
}, 
{ 
"lightness": 18 
} 
] 
}, 
{ 
"featureType": "road.local", 

我使用此代码更新标记

1 个答案:

答案 0 :(得分:1)

你应该做这样的事情。由于我不知道ajax调用你想让我嘲笑它而我正在调用返回 lat-lng 对象的$ionicPlatform.ready(function()..函数,如示例所示

fakeAjaxCall