Google地图附加数据

时间:2015-05-27 13:40:01

标签: php json maps

如何从json获取url数据以在此地图中设置:

/* global document */
jQuery(document).ready(function(){

/***
Adding Google Map.
***/

/* Calling goMap() function, initializing map and adding markers. */
jQuery('#map').goMap({
    maptype: 'ROADMAP',
    latitude: 40.760651, 
    longitude: -73.930635, 
    zoom: 13,
    scaleControl: true,
    scrollwheel: false,
    markers: [
        {latitude: 40.739323, longitude: -73.993807, group: 'airport', icon: 'http://localhost/zoom/style/default/images/marker-airport.png', html: {
            content: 'Lorem ipsum dolor sit amet.<br /><a href="company-page.html">Read More</a>'
        }},
        {latitude: 40.759090, longitude: -73.918619, group: 'airport', icon: 'http://localhost/zoom/style/default/images/marker-airport.png', html: {
            content: 'Lorem ipsum dolor sit amet.<br /><a href="company-page.html">Read More</a>'
        }},
        {latitude: 40.750898, longitude: -74.004278, group: 'airport', icon: 'http://localhost/zoom/style/default/images/marker-airport.png', html: {
            content: 'Lorem ipsum dolor sit amet.<br /><a href="company-page.html">Read More</a>'
        }},
        {latitude: 40.733210, longitude: -74.062300, group: 'restaurant', icon: 'http://localhost/zoom/style/default/images/marker-restaurant.png', html: {
            content: 'Lorem ipsum dolor sit amet.<br /><a href="company-page.html">Read More</a>'
        }},
        {latitude: 40.716818, longitude: -73.983164, group: 'restaurant', icon: 'http://localhost/zoom/style/default/images/marker-restaurant.png', html: {
            content: 'Lorem ipsum dolor sit amet.<br /><a href="company-page.html">Read More</a>'
        }},
        {latitude: 40.714216, longitude: -73.948317, group: 'restaurant', icon: 'http://localhost/zoom/style/default/images/marker-restaurant.png', html: {
            content: 'Lorem ipsum dolor sit amet.<br /><a href="company-page.html">Read More</a>'
        }},
        {latitude: 40.739323, longitude: -73.993807, group: 'shop', icon: 'http://localhost/zoom/style/default/images/marker-shop.png', html: {
            content: 'Lorem ipsum dolor sit amet.<br /><a href="company-page.html">Read More</a>'
        }},
        {latitude: 40.759090, longitude: -73.918619, group: 'shop', icon: 'http://localhost/zoom/style/default/images/marker-shop.png', html: {
            content: 'Lorem ipsum dolor sit amet.<br /><a href="company-page.html">Read More</a>'
        }},
        {latitude: 40.750898, longitude: -74.004278, group: 'entertainment', icon: 'http://localhost/zoom/style/default/images/marker-entertainment.png', html: {
            content: 'Lorem ipsum dolor sit amet.<br /><a href="company-page.html">Read More</a>'
        }},
        {latitude: 40.733210, longitude: -74.062300, group: 'realestate', icon: 'http://localhost/zoom/style/default/images/marker-realestate.png', html: {
            content: 'Lorem ipsum dolor sit amet.<br /><a href="company-page.html">Read More</a>'
        }},
        {latitude: 40.716818, longitude: -73.983164, group: 'sports', icon: 'http://localhost/zoom/style/default/images/marker-sports.png', html: {
            content: 'Lorem ipsum dolor sit amet.<br /><a href="company-page.html">Read More</a>'
        }},
        {latitude: 40.739323, longitude: -73.993807, group: 'cars', icon: 'http://localhost/zoom/style/default/images/marker-cars.png', html: {
            content: 'Lorem ipsum dolor sit amet.<br /><a href="company-page.html">Read More</a>'
        }},
        {latitude: 40.759090, longitude: -73.918619, group: 'education', icon: 'http://localhost/zoom/style/default/images/marker-education.png', html: {
            content: 'Lorem ipsum dolor sit amet.<br /><a href="company-page.html">Read More</a>'
        }},
        {latitude: 40.714216, longitude: -73.948317, group: 'garden', icon: 'http://localhost/zoom/style/default/images/marker-garden.png', html: {
            content: 'Lorem ipsum dolor sit amet.<br /><a href="company-page.html">Read More</a>'
        }},
        {latitude: 40.750898, longitude: -74.004278, group: 'mechanic', icon: 'http://localhost/zoom/style/default/images/marker-mechanic.png', html: {
            content: 'Lorem ipsum dolor sit amet.<br /><a href="company-page.html">Read More</a>'
        }},
        {latitude: 40.714216, longitude: -73.948317, group: 'offices', icon: 'http://localhost/zoom/style/default/images/marker-offices.png', html: {
            content: 'Lorem ipsum dolor sit amet.<br /><a href="company-page.html">Read More</a>'
        }},
        {latitude: 40.733210, longitude: -74.062300, group: 'advertising', icon: 'http://localhost/zoom/style/default/images/marker-advertising.png', html: {
            content: 'Lorem ipsum dolor sit amet.<br /><a href="company-page.html">Read More</a>'
        }},
        {latitude: 40.714216, longitude: -73.948317, group: 'industry', icon: 'http://localhost/zoom/style/default/images/marker-industry.png', html: {
            content: 'Lorem ipsum dolor sit amet.<br /><a href="company-page.html">Read More</a>'
        }},
        {latitude: 40.716818, longitude: -73.983164, group: 'postal', icon: 'http://localhost/zoom/style/default/images/marker-postal.png', html: {
            content: 'Lorem ipsum dolor sit amet.<br /><a href="company-page.html">Read More</a>'
        }},
        {latitude: 40.714216, longitude: -73.948317, group: 'libraries', icon: 'http://localhost/zoom/style/default/images/marker-libraries.png', html: {
            content: 'Lorem ipsum dolor sit amet.<br /><a href="company-page.html">Read More</a>'
        }}
    ]
});

    console.log($.goMap);


/* Hiding all the markers on the map. */
for (var i in $.goMap.markers) {
    if (this[i] !== 0) {
        $.goMap.showHideMarker(jQuery.goMap.markers[i], false);
    }
}

/* Revealing markers from the first group - 'airport' */
$.goMap.showHideMarkerByGroup('airport', true);

/* Processing clicks on the tabs under the map. Revealing corresponding to each tab markers. */
jQuery('.map-cat li a').click(function(event) {
    /* Preventing default link action */
    event.preventDefault();
    /* Getting current marker group name. Link ID's and marker group names must coincide. */
    var markerGroup = jQuery(this).attr('id');
    /* Changing current active tab. */
    jQuery('.map-cat li').removeClass('active');
    jQuery(this).parent().addClass('active');
    /* Hiding all the markers on the map. */
    for (var i in jQuery.goMap.markers) {
        if (this[i] !== 0) {
            jQuery.goMap.showHideMarker(jQuery.goMap.markers[i], false);
        }
    }
    /* Revealing markers from the corresponding group. */
    jQuery.goMap.showHideMarkerByGroup(markerGroup, true);
});

});

我需要从URL读取数据 不是静态数据 我有php数组输出json需要使用它

        $data[] = array(
            'latitude' => $value['latitude'],
            'longitude' => $value['longitude'],
            'group'     => $value['post_category'],
            'icon'      => 'http://localhost/zoom/style/default/images/marker-airport.png',
            'html' => array('content'=>$value['post_title']),
        ); 

echo json_encode($data);

不是标记中的数据:[]

0 个答案:

没有答案