开发者

How to add points in google maps v3 with jQuery callback?

开发者 https://www.devze.com 2023-04-08 21:30 出处:网络
var url = \'http://tw.tranews.com/map/dStores.asp?x1=\' + latlng.x1 + \'&x2=\' + latlng.x2 + \'&y1=\' + latlng.y1 + \'&y2=\' + latlng.y2;
var url = 'http://tw.tranews.com/map/dStores.asp?x1=' + latlng.x1 + '&x2=' + latlng.x2 + '&y1=' + latlng.y1 + '&y2=' + latlng.y2;
    $.get('proxy.php', {url: url}, function (resp) {
        console.log(resp);
    }, 'XML');

Excuse me guys, I want to add points in google maps v3 with jQuery callback, but I don't know how can do it. I've searched over the web, but I can't find anything. I n开发者_如何学JAVAeed your help!!!!!! plz!


Have you used the maps api at all? Generally this is pretty simple:

  • Have your MAP in JS globally visible
  • Your request should return JSON (echo '{lat:1,long:1}')
  • And then add a marker to your map

Look around in the google api to fine

TO add a marker to the map you go like this:

var myLatlng = new google.maps.LatLng(resp.lat,resp.long);
var marker = new google.maps.Marker({
  position: myLatlng,
  title:"Hello World!"
});

// To add the marker to the map, call setMap();
marker.setMap(map);  //whereas map is your map object

That's the way i'd do it, to find out more look up the google maps api: http://code.google.com/intl/de-DE/apis/maps/documentation/javascript/overlays.html http://code.google.com/intl/de-DE/apis/maps/documentation/javascript/reference.html#Marker

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号