Exact same coordinates on Google Maps API - javascript

I am using the Google Maps API through the Biostall Library. I am also using the MarkerClusterer function in it.But if I have a couple markers on the exact same location the markers won't split up. What would be the best way to solve this? I was thinking of adding a small random number to those exact same coordinates so that they would be seperate.

Why do you think they should split up?
If they are closer than MarkerClusterer's minimum distance (a configurable option) and you are above the maximum zoom (also a configurable option) and your minimum cluster size is 2 (yup, configurable too) then those two markers should appear as a blue cluster of two.
If you zoom enough, you won't see the cluster anymore, just the markers (which is an indication that MarkerClusterer is showing you the original markers). And if the clusters are in the same position, then it isn't up to MarkerClusterer to split them.
Perhaps you should give a look at OverlappingMarkerSpiderifier for that funcionality.

Related

Leaflet getting slow when there are huge amount of custom markers(1k-10k)

I'm using leaflet to show a floor plane. I have to add markers on the floor. There are two types of shape of the marker, circle and rectangle. when marker amount cross 1k, map rendering became slow and performance also.All these things I'm doing in android webview. I need help to optimize this process.
I think that is totally normal with that huge amount of markers. A common way is to use Marker Clustering. This way your huge amount of markers gets grouped into a smaller amount while still showing the needed informations to the user.
Take a look at this clustering plugin for Leaflet: https://github.com/Leaflet/Leaflet.markercluster

Arcgis javascript api, show symbols according to zoom extent

I am making a map based on arcgis js api. I have a lot of symbols drew on graphiclayer but they are too dense and even overlapping with each other.
How could I make my map showing less points if I zoom out and more points if I zoom in ? I think in this way, overlapping would no more exist.
Thanks.
You could have a look at min and max scale of the GraphicsLayer object:
https://developers.arcgis.com/javascript/3/jsapi/graphicslayer-amd.html#maxscale
Then determine what scales are you interested in. This should stop the symbols from drawing if you zoom out too far out.

Placing markers for 6000+ locations using Google Maps (or some other web & mobile platform)

The closest example of what I'm trying to accomplish is a store locator. I have 6,000+ locations that need to be plotted onto a map of Canada.
My original plan was to use Google maps to place markers on each location, but it doesn't make sense to plot them all every time someone attempts to view the map, or various parts of the map.
How does one only put markers on the locations in view? Do I have to send the geo data of all 6000 locations to the client each time they load the map?
Is this doable with maps? (I'm sure it's got to be) Or is there a better service for this kind of thing?
Definitely do not draw all the locations at the same time if they are not all visible. Consider using MarkerManager (article here) or MarkerLight (code: http://gmaps-samples.googlecode.com/svn/trunk/manymarkers/, demo: http://gmaps-samples.googlecode.com/svn/trunk/manymarkers/randommarkers.html). If your initial map and data is such that all the markers would be visible initially, this is definitely the way to go.
You can also use the GEvent object (docs) to detect a "move" event, then check the current display coordinates, draw any that are in bounds. This is the best route if your initial map is too zoomed or small, and/or your marker set is too large to fit on the map's initial view. Your user will be moving the map around, so you can react to that movement and only draw the relevant markers. Take a look at http://econym.org.uk/gmap/gevent.htm for a list of other GEvent events (couldn't find an official list on the API), you might also want to watch "zoom" events.
The two methods can also be combined.
You can use getBounds() to determine the viewable portion of the map. I'd use this data to request from the server all locations within those bounds. Use the bounds_changed event to monitor changes to the viewport and request additional locations as necessary. You'll probably want to set either a minimum zoom level, or maximum number of results to avoid displaying too many locations than is reasonable. Eg, when the map is zoomed out to display all of Canada in a single view.

Make google maps polyline appear below street names?

I'm making a subway map. The "transit" option on the official google maps shows their polyline below street/town names, but I can't figure out how to make mine do the same. Changing the zIndex to 0 (or negative numbers) doesn't work. Anyone know how to do this? Thanks.
Google Maps has several panes where the map components are being placed. Unfortunately for you the map tiles are placed below all those panes. Z-index has no effect if something is in higher pane, it only affects the order of overlays in the same pane.
Moreover map tiles are single images where all the map data are rendered. Therefore you can't place an overlay below some of the data rendered on the map tiles.
Theoretically, there might be a way to achieve this, but it's very difficult and I'm not even sure if it would work. Using styled maps you could create a base map type and an overlay map type. And then you could try to place the polylines between those two map types. Be sure there are many drawbacks:
I haven't tried to use styled map as an overlay map type so I'm not sure it would work.
Overlay map type is placed in the lowest map pane just above the base map. But polylines that are offered by Google Maps are rendered in higher pane and you can't place them into the lowest map pane.
Therefore it would be necessary to create your own special overlay layer or overlay map type containing the polylines. That is a lot of work! And then add it to the lowest map pane below the overlay map type.
OK, that's theory. Lots of hacking and uncertain outcome. I wouldn't do it that way!

Determining if a marker is visible in Google Maps

I am developing a Google Maps application and I've run into this problem. I need to remove all markers which are out of bounds from the map.
Is there any simple way of doing this, besides keeping an array and looking at the latlng of each marker?
I cannot use MarkerManager because I have way too many points. I don't want to use clearOverlays() because it would close any open marker.
Any help would be appreciated.
If you don't want to look at each marker individually then cluster them into some sets initially and calculate the bounds of the set.
You can then show or hide the sets depending on what is currently showing on the map (you can find the boundary of the map using GMap2.getBounds() ).
How many points are we talking about?
Update
A. About 65K.
I can see why you can't create 65K GMarkers when the page loads. That will take over 5 seconds.
I'd cluster them into groups of 200 ish and when the edge of the group gets within a 1/4 map width outside of the displayed edge then find, create markers and display the adjacent group. It it goes outside of 1/2 a map width of the outside edge then hide the group.
Other alternatives are to use a third party library such as
Cluster Marker - http://googlemapsapi.martinpearman.co.uk/articles.php?cat_id=1
Clusterer - http://www.acme.com/javascript/#Clusterer

Categories

Resources