Gmaps (Google Maps) addon

Gmaps - JS API Interactive search

M1564c441dd8354bf27fa3cbd31b6c8b2d
ExpressionEngine Code





{exp:gmaps:init}
{exp:gmaps:api
    center:address="heerde"
    width="100%"
}


$(function(){
    $('form').submit(function(){
        //geocode address
        EE_GMAPS.api('geocode', {
            address : $('input[name="address"]').val(),
            callback : function(result, type){

                //remove old markers
                EE_GMAPS.api('removeMarkers', {
                    mapID : 'ee_gmap_1'
                });

                //parse result
                result = $.parseJSON(result);

                //add marker
                EE_GMAPS.api('addMarker', {
                    mapID : 'ee_gmap_1',
                    lat: result[0].latitude,
                    lng: result[0].longitude,
                    title: result[0].city
                });

                //Fit the map
                EE_GMAPS.api('fitZoom', {
                    mapID : 'ee_gmap_1',
                    zoomLevel : 11
                });

            }
        });
        return false;
    });
});