Saturday, 15 June 2013

javascript - How do I change the position of a Google Maps marker? -



javascript - How do I change the position of a Google Maps marker? -

i have next code map i'm working on , i'd see if can set custom markers throughout. problem can't seem first marker alter position no matter if input latitude , longitude. perhaps i'm entering info incorrectly.

<!doctype html> <html> <head> <meta name="viewport" content="initial-scale=1.0, user-scalable=no"> <meta charset="utf-8"> <title>umapp</title> <style> html, body, #map-canvas { height: 100%; margin: 0px; padding: 0px } </style> <script src="https://maps.googleapis.com/maps/api/js?v=key"></script> <script> function initialize() { var mylatlng = new google.maps.latlng(41.160531, -73.256303); var mapoptions = { zoom: 16, center: mylatlng } var map = new google.maps.map(document.getelementbyid('map-canvas'), mapoptions); var marker = new google.maps.marker({ position: 41.159317, -73.257443, map: map, title: 'hello world!' }); } google.maps.event.adddomlistener(window, 'load', initialize); </script> </head> <body> <div id="map-canvas"></div> </body> </html>

try

var marker = new google.maps.marker({ position: new google.maps.latlng(41.159317, -73.257443); map: map, title: 'hello world!' });

javascript html google-maps google-maps-api-3

No comments:

Post a Comment