How to hide completely a map in OpenLayers? - gis

I made an OpenLayers map, which has several WMS and WMTS layers.
Of course, I can hide an HTML element of the OpenLayers map by changing the "display" style.
But I noticed that data fetching still happens for each layer.
So what is the elegant way to hide a map in OpenLayers?
PS: I do not want to change the "visible" property of each layer into "false".
Thank you.

olMap.setTarget(null);
Thank you, Mike!

Related

Custom layer/overlay in google maps

Is it possible to create custom layers/overlays in google maps?
As an example, would it be possible to have one layer with polygons, another with circles, and a third with markers? and then hide/show these layers individually?
I tried looking at the documentation, but the layers seems to only be a fixed set of predefined layers. And overlays seems to only support image overlays.
Any help on this is appreciated.
I'm not sure if there exists a better way to do this, but I've found a workaround to a similar problem. My example utilizes markers and polylines, but it should be easy to extend the functionality to circles and polygons too.
Link to JSFiddle
Basically it works like this:
Initialize the map.
User selects an option what he would like to see on the map.
Click triggers a method (see HTML part of the fiddle) in the map object that first clears the map and then pushes new overlays on map.
The data that is currently shown on map is stored in arrays, and the map clearing method simply goes through these arrays and checks if there exists any content on map, and removes them if does.
Hope this helps. Cheers!

Hiding the base map in Google Maps V2

Does anyone know how to hide the base map in Google Maps V2? I've added the following lines in my attempt to remove the standard map types, but it seems to insist on showing some sort of base map:
map.removeMapType(G_SATELLITE_MAP);
map.removeMapType(G_HYBRID_MAP);
map.removeMapType(G_AERIAL_MAP);
map.removeMapType(G_PHYSICAL_MAP);
I'm adding a KML-overlay using GGeoXml, and that's basically all I want to show. I've also tried to add a blank white KML-layer between the base map and the actual data, but with no luck. Anyone out there who knows how to hide or disable the base map?
In case anyone's having the same issue, I ended up solving it by simply making all the Google-generated map images transparent using jQuery:
jQuery('#map img').css('opacity', '0').css('filter', 'alpha(opacity=0)').css('-moz-opacity', '0').css('-khtml-opacity', '0');
The selector finds all img-tags below the map div id and sets opacity to 0 in most browsers. Left to display on the map is only the KML overlay, which was just what I wanted.

Google maps markers are hidden behind each other

I have a problem with markers hidden behind other markers.
The problem occurs when the addresses are too close to each other. e.g. street 20, street 22.
Changing zIndex will not help, because that is just "stacking".
How can I "float" the markers so that they are all visible on the map?
I recommend you look into marker clustering.
http://google-maps-utility-library-v3.googlecode.com/svn/trunk/markerclusterer/examples/advanced_example.html
UPDATE:
Google now support marker cluserting via a native library: https://developers.google.com/maps/documentation/javascript/marker-clustering
is this any use to you - it's called 'Spiderfier':
http://blog.mackerron.com/2011/06/22/overlapping-marker-spiderfier/
https://github.com/jawj/OverlappingMarkerSpiderfier
It might help to use smaller markers. When I had this problem, I changed the size of my marker images from 20x34 px down to 20x20 px.
So,you can use mysql spatial extensions and MBRContains(RectangleAroundYourPoint,GeometryColumnOfYourTable)
-if of course your table have a geometry column which is easy(upon creation you choose i.e. point as the column type,and when performing an insertion you have to do it with GeomFromText)-
to check if another place exist within that rectangle and if it is move the newcoming place until the mbrcontains return false or something like that.
Hope it helps
I use marker clusterer and had the same problem. I add a small random number to coordinates. I do not want to change the locations of markers so much therefore in satellite mode problem still exists but in map mode we can zoom much more.
This may not be a good solution but good enough for my application.

Google Maps API (static) - custom marker not showing up

URL:
http://maps.google.com/maps/api/staticmap?center=40.714728,-73.998672&markers=icon:http://tinyurl.com/2ftvtt6&zoom=12&size=400x400&sensor=false
I have no clue what I'm doing wrong here.
Developer Guide:
API - Custom Icons
...markers=icon:url[stop]&zoom=...
It seems that you defined marker style, but didn't define marker location. It should be:
http://maps.google.com/maps/api/staticmap?center=40.714728,-73.998672&markers=icon:http://tinyurl.com/2ftvtt6|40.714728,-73.998672&zoom=12&size=400x400&sensor=false
I had some problems with the markers, too.
Maybe these hints help other guys
Marker should be max 64x64 pixels in size
long marker filenames can cause issues
always define a marker location - see accepted answer
Another point I wanted to add for future reference. Don't use svg files. They won't be rendered in the final map image.

Google Maps: Traffic on top of Custom Map

I want to add traffic information to my custom map. Currently I'm using a Tile Layer Overlay on my Google Map to display custom map tiles. When I try to add GTrafficOverlay to my map, my custom map tiles display above the traffic information. Is there any way to display the traffic above my GTileLayerOverlay?
(Using the JavaScript api)
You should be able to do this in V3. Take a look at this sample: http://code.google.com/apis/maps/documentation/v3/overlays.html#ImageMapTypes
I tried this out and wasn't able to find a solution to the problem. There is nothing in the GTrafficOverlayOptions and I couldn't find anything in the references about the z-order of this stuff. I have suspect that this isn't possible.
Would love to see an alternative answer showing that I am wrong.