javascript - Add a marker to an embedded google map? -
i'm having hard time adding marker map. used use map engine , embed maps option has become limited in new maps. managed embed map new design using function, haven't been able manage add red marker it. code:
function initialize() { var map_canvas = document.getelementbyid('map_canvas'); var map_options = { center: new google.maps.latlng(-34.443809, -58.866677), zoom: 14, maptypeid: google.maps.maptypeid.roadmap }; var map = new google.maps.map(map_canvas, map_options); } google.maps.event.adddomlistener(window, 'load', initialize);
i think add marker must this:
var i=new google.maps.marker({ position:new google.maps.latlng(-34.443809,-58.866677), map:map_canvas })
but can't figure out how documentation. how can add marker middle of map?
function initialize() { var map_canvas = document.getelementbyid('map_canvas'); var map_options = { center: new google.maps.latlng(-34.443809, -58.866677), zoom: 14, maptypeid: google.maps.maptypeid.roadmap }; var map = new google.maps.map(map_canvas, map_options); var i=new google.maps.marker({ position:new google.maps.latlng(-34.443809,-58.866677), map:map // <------------------ needs google.maps.map object }) } google.maps.event.adddomlistener(window, 'load', initialize);
Comments
Post a Comment