HERE Maps - Can you view traffic from further zoom? - javascript

I am currently working with HERE Maps API and I currently have a traffic toggle up and working. The problem I am having is that when I toggle on the traffic layer using this method it seems to not render. I have to zoom in quite a bit on the map to actually see the traffic layer get rendered in. Is this how it is designed or is there a way to view traffic from a further zoom level?

With H.ui.ZoomControl.Options, default zoom level while rendering for a map can be changed. If you think that you really need to zoom a lot after the traffic layer gets loaded, you can optimise using that. After that, can set zoom_min and max value to further check the traffic details in the map.
Please refer following link to further check for zoomcontrol options >
https://developer.here.com/documentation/maps/3.1.14.0/api_reference/H.ui.ZoomControl.html

Related

BingMaps Is it possible to disable clustering below certain zoom level?

My map pushpins are relatively close to each other and even on a big zoom I still see them clustered.
I solved this issue by spreading the clustered pushpins by some random distance 5-10 meters.
I need more accurate solution so my idea is to disable the clustering below the certain zoom level, but I didn't find any way how to do it.
There is no option to disable clustering in the clustering layer in Bing Maps, but what you can do is monitor the zoom level of the map, and when it gets to a certain point, hide the cluster layer and load a new layer that isn't clustered. Unfortunately this means having two copies of your data in memory.
If you haven't fully committed to using the Bing Maps platform, you may also want to take a look at Azure Maps. The Azure Maps web SDK does things a bit differently where you would keep your data in a single data source and attach rendering layers to it. Clustering is turned on in the data source and has a max zoom level option for clustering.
Here is some examples: https://azuremapscodesamples.azurewebsites.net/index.html?search=cluster
Here is documentation: https://learn.microsoft.com/en-us/azure/azure-maps/clustering-point-data-web-sdk
There is an option clusteringEnabled now on ClusterLayerOptions which will disable clustering without losing the whole layer.
eg:
Microsoft.Maps.Events.addHandler(this.map, 'viewchangeend', () => {
// de-cluster at highest zoom level
this.clusterLayer?.setOptions({
clusteringEnabled:
this.map.getZoom() < this.map.getZoomRange().max
});
});

Using Google Maps API with custom tiles

So, basic gist is, I have my own tiles of not the real world I'd like to display with the Google Maps viewer. I've found examples of how to split an existing single image into tiles for use with it, but nothing that deals with setting up your own tiler.
I have map data such as this:
https://dl.dropboxusercontent.com/u/44766482/superimage/index.html
Which right now is just a bunch of 1600x1600 images in an html table. This naive method works, but I'd like to switch to the more robust google api for better zooming and smarter streaming of the image data.
I've been unable to find a good example of how to generate your own tiles for the zoom levels and bring it together with some html/js.
If you want some more information for the goal process;
I have a python script that can output any size tiles of the map, at any zoom level. I'd like to bundle those together into a google maps api website. But in my own efforts I have not found a good example or documentation of how to do that. For one, I can only find examples of how the zoom levels work for the real world map, but not for a custom one.
Edit:
Got most things working as I want them, but I'm still confused regarding the "center" that can be set, as it's in lat and lng, which don't apply. I'd also like to set boundaries as currently it tries to load .png files outside of the maps range.
My current progress:
https://dl.dropboxusercontent.com/u/44766482/googlemapspreview/index.html
I think what you are looking for is the google maps imageMapTypes:
https://developers.google.com/maps/documentation/javascript/maptypes#ImageMapTypes
Basically, each zoom level is the 4 lower zoom tiles combined. A Projection function can be skipped to get orthogonal mapping.

How to refresh Bing Maps AJAX?

I create Bing Maps AJAX control and initialize it with always the same values: lat, lng and zoom level. This is a default aerial map type and a maximum zoom level. And every time I get the following image:
http://i50.tinypic.com/acturr.jpg
There is no documented method (or not) to refresh the current area so I should to do zoom out and zoom in using mouse every time, it's annoying. For Google Maps I found a useful trick:
google.maps.event.trigger(this.map, 'resize');
Does Bing Maps AJAX API have something similar?
I have recently encountered a similar issue on Bing maps AJAX V7:
On some browsers (Mostly on Chrome), if the map is not present on the viewport (you have to scroll to reach it), then it initializes improperly.
I have reported the issue to MSDN but didn't get any useful answer: https://social.msdn.microsoft.com/Forums/en-US/439c33bc-a1ed-4e74-a019-f7fecb809030/scroll-issue-on-chrome-with-ajax-v7-control
To fix this issue, I have used two things:
First of all, I had to find a way to force the Bing map to refresh (didn't found any solution on the internet nor object method to do that). After a lot of tests I came out with a solution:
map.setMapType(Microsoft.Maps.MapTypeId.mercator);
setTimeout(function(){map.setMapType(Microsoft.Maps.MapTypeId.auto);}, 1)
Indeed, changing the viewport to "mercator" then back to another forces the map to refresh (the setTimeout makes the action asynchronous)
I then have added a lib that triggers an event when an element is entering the viewport in order to trigger the force refresh every time the map enters the viewport

Custom InfoWindow size/pointer position in Google Maps API

I have a map application that can be seen here:
http://chrismcaleenan.com/map/?page_id=25
Each of the Malaysian states in the application will have an InfoWindow that displays additional information. You can see an example of this by mousing over 'Kedah' either in the main data table on the right or on the state itself in the map.
The problem, as you can see, is that the map pans in order to position the InfoWindow. Is there a way to fix the map position and set the InfoWindow size or position so that it is fully displayed without panning? In the Kedah example, one could have the InfoWindow positioned directly to the right and/or use a shorter tail.
One option would be to create a custom graphic for each state, but I'd rather avoid this as I will be running into the same issue with add'l data (e.g. click Kedah to zoom - will have InfoWindows on all data points on zoom).
If you're playing around double-clicking the water will zoom back out and reset map.
Thanks!
Yes, and sometimes the pan pulls the mouse outside of the state, which causes the InfoWindow to disappear. I know that's not what you want. The Google Maps demo catalog includes a sample that I think will give you what you want for your map. It's named SmartInfoWindow. Take a look, click on some of the markers, check out how the SmartInfoWindow behaves, and see if that might help you achieve what you want. It's not perfect, but it keeps the pan at the absolute minimum.

Parse kml with geoxml3 in maps api v3 but stop rebuilding the sidebar when bounds/zoom changed

I've found a great page that demonstrates many uses of the Google Maps Api v2 and v3.
I tried to understand each line of the javascript and make something similar to what can be found on the page linked above.
However I can't understand two things:
In my application I don't want to rebuild the sidebar every time the zoom/bound/mapcenter changes. Currently the sidebar shows only placemarks that are visible on the current mapview. When the user zooms in and a placemark goes out of the view it disappears from the sidebar too. It could be annoying when you already scrolled somewhere and with only a little zooming you loose your scrolled status. Also if you bind events to sidebar elements, changing the view on the map rebuilds the sidebar and your events are finished.
I tried to rewrite the piece of code that creates categories from the placemark's styleurl property to apply to polylines as well not just markers, but I have no luck.
If you are deep in this kind of work please point me to the right direction.
Thanks.

Categories