开发者

Can and How import markers and pop-ups with query mobile and google maps

I am having a little trouble creating pop-up's using jquery maps. I can get the makers showing, but can't seem to get the pop-ups working with the markers.

Any help welcome on this:

<script type="text/javascript">
    function loadMap() {
        SyntaxHighlighter.all();
        $('#map_canvas').gmap({ 
          'center':new google.maps.LatLng(cc_maps_lat, cc_maps_long),
          'zoom':cc_maps_zoom, 
          'streetViewControl': cc_streetView,
          'mapTypeControl' : true, 
          'navigationControl' : true,

          'callback': function() {
            $.getJSON( '_config/pips.json', 'category=activity', function(data) { 
                $.each( data.markers, function(i, m) {
                    $('#map_canvas').gmap('addMarker', { 'position': new google.maps.LatLng(m.lat, m.lng) } );
                });
            });
          }

        });
    }
</script>

<div id="gmap" data-role="page">
    <div data-role="header" data-position="inline">
        <h1>Maps</h1>
        <a href="#home" data-icon="home" class="ui-btn-right" data-iconpos="notext" data-transition="slidedown">Home</a&开发者_JAVA百科gt;
    </div>
    <div data-role="content"> 
        <div id="map_canvas" style="height:440px;"></div>
        <!-- <div id="map_canvas" style="height:440px;"></div> -->
    </div>
</div>

And the JSON file:

{"markers":[{"lat":51.222629,"lng":-1.229959,"title":"Test"}]}


Note the appended click function which will go in your $.each function.

$('#map_canvas').gmap('addMarker', {
'position': new google.maps.LatLng(marker.Lat, marker.Lng), 
'bounds': true
}).click(function() {
$('#map_canvas').gmap('openInfoWindow', { 'content': marker.City }, this);
});

Then amend the marker.City to your JSON feed item required.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜