I've got a tile layer that I want to remove and replace with another one in Google Maps. My tile layer is defined in MapOptions using GetTileUrl to call a function.
For instance, I want to be able to remove a county layer and replace it with a census tract one.
When I try to do this it only loads the new layer when I pan the map. I think I need to remove the old tiles from Google's cache (as if I turn browser caching turned off this still happens).
I've tried the map "resize" event, but it doesn't work.
Do I need to set the map to null and reinitialize everything? Or can I just reload my map tile layer?
When I change the layer, the URL for the tile loading changes - so I'm guessing that adding a fake parameter won't help me.
The code is pretty long (and has extra stuff in it), but if you want to see this in action you can go to JusticeMap.org
var jmapMapType = new google.maps.ImageMapType(jmapTypeOptions);
map.overlayMapTypes.push(jmapMapType);
I needed to store the jmapMapType in a global variable.
Then I can remove it, and add it back. This reloads the tiles:
map.overlayMapTypes.removeAt(0);
map.overlayMapTypes.push(jmapMapType);
Related
I am attempting to add tabs to the infowindow of this site http://nctcog.org/trans/data/trafficcounts/index.asp
As I have literally thousands of points stored in a database, as the map center changes, I grab the map boundaries and pass them to a page that build the KML file which then loads them using google.maps.KmlLayer. Most of the data in the infowindow is stored in the same table as the lat,lon and I load it along with the coordinates when I build the KML file.
I have tried several methods of manipulating the tag with no success.
I know there is a listener that can be added to manipulate the infowindow, but since I'm not adding my markers with a listener, how do I tie it to the correct marker?
The hard part is manipulating your markers from a KML file. As far as I have tried, there's no way to do so when you are using KMLayer. Since you are creating KML on the fly, it makes things easier.
Luckily :) I worked on a KML question recently and have a starter file. An annoying "feature" is that the AJAX calls forced me to put the HTML and KML in the same public computer. I couldn't work offline. You could try a local web server, I didn't.
https://files.nyu.edu/hc742/public/googlemaps/kmlcircle.html
The key idea is to replace the default functionality of createMarker shown below with the name of your own function. In this case I was adding circles, in yours, you need to add InfoWindows.
geoXml = new geoXML3.parser({
map: map,
createMarker: addCircle});
Adding tabs to your infowindow can be done in at least two ways. The JQuery way and Tabber Way (once this page is loaded click on the green line)
i'm creating a simulation model using Google maps, i have created a new KML layer and marked few areas which are dangerous to users to go through, now i want to add a moving object to resemble a person on top of it and give a warning when that object nearing the area, does any one have the idea of doing animation of that kind using Google maps?
If you are talking about a moving marker i think you can use the setPosition of the marker object in a for loop feeding it with the coords of a line let's say.
I'm working on a project where, after creating some nice code for creating polygons and attaching mouse events to them, the addition of KML layers (mainly placemarkers) results in uncooperative behaviour between the placeholders of the KML layer and the generated polygons.
If I create the polygons first and set the KML file afterwards, clicking on the placemarkers brings up the infowindow () as expected. However, mouseovers on the polygons below yield no result, whereas before they get highlighted and are clickable (which they aren't).
Setting the KML layer to null doesn't help either. The placemarkers disappear, but my polygons aren't registering.
When I first call the KML with placemarkers, the polygon layer called later goes on top of the placemarkers. The polygons are opaque, so you can see the placemarkers like you could through a window, but you can't click or interact with the placemarkers.
Setting the polygons to null results in the same behaviour as before. Placeholders still cannot be clicked on.
Help? I couldn't find a zIndex reference for the KML layer code, and I'm hoping that's all it is. I read somewhere else - and imagine this to be true - that the KML and user-gernated content "layers" are conflicting with one another - the latter one that's put on the map takes focus, captures events, etc. I would've thought that it wouldn't matter, in the same way that you can have divs on top of other divs, especially if you use indexing.
If you simply want to display the information in the KML layer and not have it react to user events, you can add the suppressInfoWindows flag to the constructor:
var myKmlLayer = new google.maps.KmlLayer('http://gmaps-samples.googlecode.com/svn/trunk/ggeoxml/cta.kml', { suppressInfoWindows: true });
This will effectively shut off all interactions and let your other layers receive interactions.
Edit: Forgot to mention that a good source of information is the Google API V3 site discussing KML layers
I am using the Google Maps Control for ASP.Net. I am adding one point which is current point of bus & polyline of the points from current point to last 10 points on the page load with showing popup on current point by default.
I am using update panel for the the refresh button. There is also one input field which takes number of record to show on polyline from current point. Now I want to reset my googlemapObject on refresh button click event so that in every refresh click completely new set of points, polylines should add and shown on google map.
Is there is any method like dispose to dispose current object of goolemap.
How to resolve this problem?
Regards,
Girish
I'm assuming that you are using the Google Maps Control for ASP.NET found at:
http://en.googlemaps.subgurim.net/
If that is the case - there is an example found on their site that will walk you through how to erase icons that are added to the map.
The sample code can be found right here:
http://en.googlemaps.subgurim.net/ejemplos/ejemplo_99000_Custom-Javascript.aspx
By implementing a custom Javascript Event you will be able to change the data on your map with the refresh button - without needing to do a whole page refresh.
I am using the Google Maps API to code a campus map for my university. On the main map, when it is being viewed in the "Map" maptype, there is a custom overlay of the campus, which is set (by using GEvent.addDomListener) to be removed when the map is viewed in Satellite or Hybrid mode. When the user gets directions, through my map, to and from the campus, a polyline and 2 markers show up, like normal. When the marker is clicked, a small popup map is display, focused on the area of campus around that particular marker.
I was wondering if anyone knew of a way to set attributes of these mini-popup-maps. I need to extend the event listener to make sure that the overlay gets taken off when the mini map is clicked out of "Map" mode. I also need to be able to set the zoom level for these maps.
Any ideas?
(code can be provided as needed, wasn't really sure what parts would be needed and didn't want to post the whole f'n thing up here.)
Doesn't look like there are any built in options to modify the infoWindow you get from the GDirection markers, but you can explicitly replace the markers once you get them back.
This post describes the process.