I have two layers, OpenStreetMap for online tiles and TMS for cached tiles from a different tile source. I know how to display each of the layers separately.
However, TMS does not contain all the tiles. So I would like to display TMS tiles first and then everything else that is not cached with OpenStreetMap. How could I do this overlapping of two layers?
The result should look just like below:
a busy cat http://tothchat.com/test/tiles.png
This two layers must be overlay (not baseLayer). Did you try this:
map = new OpenLayers.Map({
div: "map",
allOverlays: true //<- all layers will have isBaseLayer set to false when they are added to the map.
});
Or set isBaseLayer parameter to false for these two layers.
Related
I have two tileset with coordinate (created from GeoJSON file):
tilest # 1. Point on map.
tilest # 2. Route on map.
Both tilesets are so big - so, I don't what to make client to download data source and filter it.
I've created custom Mapbox style and added two layers with these tilesets as data sources.
I want to show the map from style:
without these custom layers
with only first layer
with only second layer
with both layers
Is it possible to do with Mapbox Static API (https://www.mapbox.com/api-documentation/#static)? Or mapbox caches and makes rasterisation from all layers in style and separate them is not possible?
In general, what is the best strategy for huge tilesets? Should I make different style for every case and switch them on client?
I've read that you can create a custom image map with tiles. Now i've seen a video where this proces is being done with LeafletJS video here
But how can i accomplish this with google maps. For instance i've the following example map of a zoo. How could i use this with tiles in google maps. Could someone point me in the right direction, tutorials, etc.
Creating tiles for map is not trivial task, and there are many utilities for that (e.g. maptiler). You should split your image to tiles, and save it in, for example, assets folder. Also you need implement custom TileProvider like in this answer of Alex Vasilkov.
But, actually, tiles necessary if you have "big" image, which can't be shown wholly due memory restriction, or you have several images for different zoom levels - in that case one tile of zoomlevel becomes 4 tiles of zoomlevel+1. Taipei zoo schamatics is not so big, so you can use GroundOverlay.
With your image as zoo drawable resource, you can use something like this:
#Override
public void onMapReady(GoogleMap googleMap) {
mGoogleMap = googleMap;
GroundOverlayOptions overlayZoo = new GroundOverlayOptions()
.image(BitmapDescriptorFactory.fromResource(R.drawable.zoo))
.transparency(0.5f)
.bearing(135)
.position(new LatLng(24.995517, 121.584058), 1000f);
mGoogleMap.addGroundOverlay(overlayZoo);
mGoogleMap.animateCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(24.995517, 121.584058), 15.0f));
}
and got something like that:
and it's zoomable, scrollable, rotatable etc.
Of course, it's just example, and you need more precisely referencing, bearing, removing unnecessary elements, etc. Also the image scheme itself is very approximate and differs from the real terrain.
I need to show a set of markers on a Google map.
I know markers can be added directly on a Google map but given that I have 3 sets of markers, one for shops, one for parks and another one for hotels, how can I show them on 3 different layers and so that later on using javascript, I be able to hide one set of markers by doing sort of:
myLayer2.setMap(null);
I have checked Panoramio layer but it needs the images first to be uploaded to panoramio, but in my case for some particular security reason I cannot upload them to panoramio. I will have images locally and set those at runtime based upon some criteria.
Is there some way to do layer based work without using panoramio approach?
The Maps-API doesn't support this kind of custom layers(as you maybe know them from other map-API's like e.g. leaflet).
But it's not hard to achieve a similar feature.
You may use a google.maps.MVCObject. for every "layer" create a property for this MVCObject and set the value of this property to null or the google.maps.Map-instance(
depending on the desired initial state of the "layer")
var myLayers=new google.maps.MVCObject();
myLayers.setValues({parks:null,shops:null,hotels:map});
//hotels initially are visible
When you want to add a Overlay...e.g. a Marker, to a "layer", bind the map-property of that Overlay to the related property of the MVCObject:
parkMarker=new google.maps.Marker({/*options*/});
parkMarker.bindTo('map',myLayers,'parks');
To toggle the display of all features within that "layer" you only need to set the property of the MVCObject:
//show the parks
myLayers.set('parks',map);
//hide the hotels
myLayers.set('hotels',null);
Demo: http://jsfiddle.net/doktormolle/UA85N/
I have many different KML layers on a Google Map (v3). Random colors of markers were assigned to each set of markers. I would like to be able to control this, however.
So far, this is what I have:
map = new google.maps.Map(document.getElementById("map-canvas"), mapOptions);
var kmlLayerOptions = { preserveViewport: true, suppressInfoWindows: true };
var Layer1 = new google.maps.KmlLayer('http://myurl.com/1.xml', kmlLayerOptions);
Layer1.setMap(map);
var Layer2 = new google.maps.KmlLayer('http://myurl.com/2.xml', kmlLayerOptions);
Layer2.setMap(map);
I need to be able to say I want Layer 1 to use blue markers and layer 2 to use red markers, but I can't seem to figure this out.
From what I can tell, there is no way to do this with the kmlLayerOptions, which is where it would seem like it would happen, so I don't see where else I could logically make this change other than directly on the layer object.
You can't change it with KmlLayer (at least currently, you could create an Enhancement request to add the functionality).
You can do it with FusionTablesLayers (import your KML into FusionTables, then use either the User Interface to set the icons or dynamic styling in the Google Maps API v3 (assuming you need less than 5 different icons, and the ones you want are available in FusionTables).
A final option would be to edit the existing KML to use the icons you want.
The KmlLayer renders according to the styling in the KML document itself, and you cannot override this in any layer options.
If you don't want to modify the KML itself, you could use a third party library such as http://code.google.com/p/geoxml3/ to render the KML on the clientside rather than having Google's servers render it, and this would give you the ability to override the rendering defaults.
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