this.grid_ is undefined with MarkerManager and Google Maps v3 - google-maps-api-3

I am updating a maps page to v3 and I am getting the following error from markermanager.js
this.grid_ is undefined - var grid = this.grid_[z]; which is on line 529
This is caused by the following code
MarkerManager.addMarker(marker);
I am creating a lot of markers and most of them are added no problem however there are a few that throw this error. On first glance all of the maker objects appear similar enough to make it work.
Any thoughts?

You may also get this error if you add markers to the manager using an array, if you set a max zoom level that's not appropriate.
eg.:
markermgr.addMarkers(markerArray,6,20);
where 6 is the minzoom and 20 is the maxzoom.
The maxzoom level used to be 17, but you can now zoom in to 20+ in some urban areas.

It turns out that this error occurs when you try to add markers to markerManager before it is loaded. To avoid this error you have to add an event listener after the markerManager is created like so...
google.maps.event.addListener(markerManager, 'loaded', function() {
//add ajax call or any other code here
});

Related

Error when moving mouse over map. No map events set

I am getting an error when moving the mouse over the map. It appears as though a mouseover/mousemove event is being fired although I haven't set any for the map. This is throwing an error in a block of code the debug window calls "eval code (8)"
The error is on "h=new O(s.lat(),s.lng())" in this function...
function SF(a,b,c,d){var e=new az(d);ep;bp;var f=c.Eb;M([Af,qs,cs,hr,gr,os,ps,ns],function(d){P[y](b,d,function(h,n,r){var s=aSn;h=new O(s.lat(),s.lng());s=c.get("projection")db;n=new Rr(h,r,n,s);var u;r=Ns(Is);h=f.Od;var x=n.Xa&&ir(n.Xa);if(f.b)s=f.b,u=f.d;else if(d==gr||x)u=s=null;else{for(var C=0;(s=h[C++])&&!(u=s.l(n,!1)););if(!u&&r)for(C=0;(s=h[C++])&&!(u=s.l(n,!0)););}if(s!=f.e||u!=f.n)f.e&&f.e.e(gr,n,f.n),f.e=s,f.n=u,s&&s.e(hr,
n,u);s?d==hr||d==gr?u=!1:(s.e(d,n,u),u=!0):u=!!x;u||(b.set("draggableCursor",c.get("draggableCursor")),e.set("title",null),delete n.Xa,Pm)})})}function TF(a,b,c){Pv;Pv;Pv;Pv;Pv}function UF(a,b){0!=Gt()lc||Ks(Is)||Qq()||rk[14]||Q(tf,function(a){a.b.b({ev:"api_watermark"})});var c=new yx(b,a[No],null),d=a.R();cp;cp;cp;cp}
Where "s" is null and therefore it cannot get the .lat or .lng properties.
I have tried setting the mouseover, mousemove and mouseout events to run "function(){}" to test if it is related to these but this did not stop the error.
Please help.
I know it's been a while, but I had the same problem and I was able to fix it by adding this at the end of the URL for the script tag:
&v=3.22
EDIT: I miscopied the fixing URL parameter

Google map how to display a dragable marker based on coordinates and return new coordinates

I have to write a script for Google Maps V3 which will do the following:
Place a marker on a map based on a set of coordinates and possbibly change the address after the page has been loaded
Allow the user the drag the mark to replace it elsewhere
Collect the new coordinates once the marker has been moved.
The first part is basic enough and should be fine, changing the address after the page is loaded should only be a matter of calling back the same function?
I am not sure where to start on the draggable marker and collecting hew coordinates.
Would anyone know of scripts / API's or where in the doc should I start?
Have you checked the Google Maps Javascript API V3 Reference to see whether the google.maps.Marker class has :
a draggable option
an dragend event
a getPosition method
Hint: The answer might just be "yes" to all three, and you don't need much else to solve your problem.

Google Maps API v3 Google Earth API integration - load Earth view on load

I'm using the google-maps-utility-library-v3 to incorporate a Google Earth API view to a Google Maps API v3 implementation. Those Google Maps API v3 / Earth API utilities have been written by user jlivni as far as I can tell, the availability of which code has helped me greatly thus far.
(very rough working prototype of my implementation is here)
The problem I have is that I want to default (on page load) to the Google Earth view, rather than (as in the prototype above) one of the Maps API v3 standard views.
I have looked at lines 81, 131 and 133 of the (uncompiled?) googleearth.js at the above link (under src) and tried the following when setting the Maps API options within my JourneyImmersionInitialiseMapLoadGPXAnimate.js ...
var myOptions = {
zoom: 18,
center: arr_lat_lon[currentTrk][currentTrkseg][0],
scaleControl: true,
tilt: 45,
mapTypeId: earthMapType,
overviewMapControl: true,
overviewMapControlOptions: {
opened: true
}
};
map = new google.maps.Map(document.getElementById("map"), myOptions);
... but get ...
ReferenceError: earthMapType is not defined
Additionally I've tried ...
mapTypeId: GoogleEarth.earthMapType,
... which results in a grey map canvas with no map type options on the top right. Once I've selected the Earth view from the page I can then change between the standard Earth API map types at the console in Firebug using ...
earth.getInstance().getOptions().setMapType(earth.getInstance().MAP_TYPE_EARTH)
... or ...
earth.getInstance().getOptions().setMapType(earth.getInstance().MAP_TYPE_SKY)
... but again, use of earthMapType or GoogleEarth.earthMapType in place of the last element results in an error at the Firebug console, this time ...
Error: Error calling method on NPObject!
Any help would be greatly appreciated.
Thanks in advance
(as I'm a newbie I can't provide more than two links in this post but wanted to add that I have looked at stackoverflow.com/questions/3039250/google-earth-integrated-with-google-maps-api-v3)
This library doesn't have a public method to switch programmatically, and if you try to do it before all the setup is in place, it will fail. Ideally there would be a callback after instantiating your GoogleEarth object, but lacking that you can hack around the issue by using the private showEarth_() method on the uncompiled JS.
Noting you have to wait an arbitrary amount of time before the plugin is ready, something like this should generally do the trick:
googleEarth = new GoogleEarth(map);
setTimeout('googleEarth.showEarth_();',1000);
This is all pretty hackish, so please file a feature request on the issue tracker to add in a supported method for switching to the Earth type programmatically.

Google Maps API V3 prevent from adding "Listing by" when placing markers after a places search

I run a search using google.maps.places.PlacesService(map) and then I place markers on the map which is fine. I do this every time the "dragend" event occurs.
But then, every time, it added on the right side of the map "Listing by yellowpages". So if I scroll 3 times, I get 3 "Listing by yellowpages". How do I remove that?
I had a similar problem using the Google Maps API. Turns out it was caused by the fact I was creating a new PlacesService object every time, and when I switched to having just the single PlacesService object, this problem went away.
So make sure you only have once PlacesService object created and linked to the map.
Show last listing-by only
lib jquery
service = new google.maps.places.PlacesService(map);
service.textSearch(request, function(request, status){
if(status==google.maps.places.PlacesServiceStatus.OK){
$('.listing-by-map').hide();
$('#map div').last().addClass('listing-by-map');
//...
}
});

Yahoo Maps API - Same code ok in Firefox, not IE7

I've implemented a simple yahoo mapping example using JQUERY.
My problem is i'm developing using my localhost, my intended target platform is to be within an Intranet environment. My thinking is that my localhost will to some extent mimic this.
I have an update, made some progress. See the code snippet below, all ok in Firefox but in IE (my target browser) it fails on the line:
var currentGeoPoint = new YGeoPoint($('#txtLatitude').val(), $('#txtLongitude').val());
What I cannot understand is why will IE allow the MAP API Code to run and manipulate the MAP object and fail on this one line.
Could this all be to do with Tools/Intranet Options/Security and trusted sites etc? My URL locally is "http://localhost:4724/LMS/Site.mvc/Details/77" if thats any help.
$(document).ready(function() {
jQuery("textarea[class*=expand]").TextAreaExpander(); // initialize all expanding textareas, new code, john s 10/08/2010
var geoPoint;
// Create a map object
var map = new YMap(document.getElementById('map'));
// Add map type control
map.addTypeControl();
// Set map type to either of: YAHOO_MAP_SAT, YAHOO_MAP_HYB, YAHOO_MAP_REG
map.setMapType(YAHOO_MAP_REG);
// Display the map centered on a geocoded location
map.drawZoomAndCenter("United Kingdom", 12);
// Add map type control
map.addTypeControl();
// Add map zoom (long) control
map.addZoomLong();
// Add the Pan Control
map.addPanControl();
// Set map type to either of: YAHOO_MAP_SAT, YAHOO_MAP_HYB, YAHOO_MAP_REG
map.setMapType(YAHOO_MAP_REG);
// Display the map centered on a geocoded location
map.drawZoomAndCenter("United Kingdom", 12);
var currentGeoPoint = new YGeoPoint($('#txtLatitude').val(), $('#txtLongitude').val()); // FAILS IN IE ON THIS LINE!! Unspecified Error popup dialogue box
map.addMarker(currentGeoPoint);
});
John
Have this working now, reverted back to original javascript, i'd hand rolled my own code and although neater was not working in IE. Glad to be out of the woods, cheers, J

Resources