google maps - how setting a location by latitude longitude in gmap3 -
good afternoon, using plugin gmap3 (http://gmap3.net), , not able set location center map , display marker.
explanation: save value of latitude , longitude in database. example "-29.165708760531277, -51.51253212137226". , screen, want open showing location. i'm trying this:
var localizacao = $("#localizacao").text(); $("#mapeditar").gmap3({ marker:{ latlng: [localizacao], draggable:true }, }, map:{ options:{ zoom: 16, maptypeid:google.maps.maptypeid.hybrid, } } });
where variable "localizacao", value longitude latitude.
but using way, not showing map. there better way this? doing wrong?
thank you
well start looks have curly brace in code
var localizacao = $("#localizacao").text(); $("#mapeditar").gmap3({ marker:{ latlng: [localizacao], draggable:true }, //}, removed map:{ options:{ zoom: 16, maptypeid:google.maps.maptypeid.hybrid, } } });
and why latlng not working [localizacao]
, because latlng takes 2 separate parameters separated comma, ["-29.165708760531277", "-51.51253212137226"]
. variable localizacao contains string in form "-29.165708760531277, -51.51253212137226" results in ["-29.165708760531277, -51.51253212137226"]
, won't work because there 1 parameter.
var lat = $("#localizacao_lat").text(); var lng = $("#localizacao_lng").text(); $("#mapeditar").gmap3({ marker:{ latlng: [lat, lng], draggable:true }, map:{ options:{ zoom: 16, maptypeid:google.maps.maptypeid.hybrid, } } });
here's jsfiddle might :)
Comments
Post a Comment