Maps example - JS API Interactive search
Template code
<script src="https://code.jquery.com/jquery-3.7.1.js" integrity="sha256-eKhayi8LEQwp4NKxN+CfCh+3qOVUtJn3QNZ0TciWLP4=" crossorigin="anonymous"></script>
<form style="margin-bottom: 10px;">
<input name="address" style="border: 1px solid green;"/>
<input type="submit">
</form>
{exp:reinos_maps:html_header}
{exp:reinos_maps:map
center:address="heerde"
width="100%"
}
{exp:reinos_maps:html_footer}
<script>
$(function(){
$("form").submit(function(){
//geocode address
REINOS_MAPS.api("geocode", {
address : $("input[name="address"]").val(),
callback : function(result, type){
//remove old markers
REINOS_MAPS.api("removeMarkers", {
mapID : "reinos_map_1"
});
//add marker
REINOS_MAPS.api("addMarker", {
mapID : "reinos_map_1",
lat: result.objects[0].latitude,
lng: result.objects[0].longitude,
title: result.objects[0].city
});
//Fit the map
REINOS_MAPS.api("fitMap", {
mapID : "reinos_map_1"
});
REINOS_MAPS.api("setZoom", {
mapID : "reinos_map_1" ,
zoom : 6
});
}
});
return false;
});
});
</script>