Gmap3 - Forum

Gmap3 exchange platform

You are not logged in.

Ads
(server costs 27.50€ per month)


#1 2012-09-27 12:02:18

dageek
Member
Registered: 2012-09-27
Posts: 1

Refresh map with JSON

Please forgive the noob post, but I'm having a real brain cramp.  I am considering using GMap3 in a real estate app where I initialize the map with summary markers for each town in a county.  This part works just fine.

On the side of the map I have a search form.  I want to use $.getJSON to get detail markers based on the user's search criteria.

What I'm having a hard time conceptualizing is what must the simple syntax to clear the map and add new markers.

Here's the code for initializing the map:

$(function(){ 
    // add the map.
    var gmap = $("#aa_gmap");
    gmap.gmap3();
};

then the json fragment.

$j.getJSON("getjson.php", function(data) {
    // now add the data.
   gmap.gmap3(
        { action:'init',
            options:{
                center:[43.9791831,-71.1203479],  
                zoom: 4,
            }
        },

        { action: 'addMarkers',markers: data,
            marker:{
            options:{
                draggable: false
            },
            events:{
                mouseover: function(marker, event, data){

                   // simple code in here

                },
                mouseout: function() {
                   // simple code in here
                },
                click: function(marker, event, data){
                   // would also love to refresh map with data from town clicked, here.
                    var map = $j("#aa_gmap").gmap3('get');
                    $j("#aa_gmap").gmap3('clear');
                    console.log(data.town);
                },
            }
            }
        },
        "autofit"
    );

});

With this setup, when a user clicks the submit button on the form, how do I refresh the map? 
How do I pass the form parameters to the getjson.php file using JQuery?

I know this should be easy!  (and probably is), but I just don't see it!

Thanks in advance,
Brian

Offline

Ads
(server costs 27.50€ per month)


#2 2012-09-27 20:24:04

jbdemonte
Administrator
From: Pourrières, France
Registered: 2011-11-21
Posts: 580

Re: Refresh map with JSON

it depends on your "data" format

Offline

Board footer

Powered by FluxBB