I need to set pointers to the map) when the map begins and b) when the map goes to get the marker For, I call my API like this:
var bounds = map.getBounds ();
And then take the border to get the right markers.
The problem is, when I put that API call inside
google.maps.event.addListener (map, "bounds_changed", function () {}) < / Code>
While dragging the map it is often called, but if I
google.maps.event.addListener (map, "idle", function () {})
map.get Bounds is unobtrusive on the start.
Editing: more code
$ (document) .ready (function () {initialize ();}); Function initialize () {mapOptions = {zoom: 13, min zoom: minimum zoom level, scrollable: false, pan control: false}; Map = new google.maps.Map (document.getElementById ('map-canvas'), map options); Google.maps.event.addListener (map, "idle", function () {myfunction ();}); }); Function myfunction () {var bounds = map.getBounds (); }
Bounds is empty!
I'm using this piece of code here: and it works fine:
var map google = null; // some things var mappoptions = // some here mapgoogle = new google.maps.Map (document.getElementById ("map"), map options); Google.maps.event.addListener (mapgoogle, 'idle', function () {var bounds = mapgoogle.getBounds (); console.log (bounds); // It is said only when "end of drag" result are given} ); Edit
Function initialize (lat, lng) {var myLatlng = new google.maps.LatLng (lat, lng); Var mapOptions = {mapTypeControl: false, streetViewControl: false, center: myLatlng, zoom: 15, maptype: google.maps.MapTypeId.ROADMAP}; Map = new google.maps.Map (document.getElementById ('map-canvas'), map options); Google.maps.event.addListener (map, 'inactive', function () {console.log (map.getBounds ());})}}; Navigator.geolocation.getCurrentPosition (function (status) {start (position.coords.latitude, position.coords.longitude);}, function (position) {start (-23.5354986, -46.6839113);}); // html and css & lt; Div id = "map-canvas" & gt; & Lt; / Div & gt; # Map-canvas {width: 400px; Height: 400 pixels; Limit: 1 px solid # ff0000; }
No comments:
Post a Comment