Maybe someone knows if it's possible to get clustered markers list. Or to know if marker is inside cluster or not. The issue is currently each marker on my map have associated polyline as well. But when two or more markers gets clustered I want to hide polylines for those markers. Would it be possible somehow?
One way to implement this would be to add the markers to a h.map.Group() while rendering them and then you would be able to find if the marker is part of the group as well as the proximity of the two markers. Another way is to look at this marker clustering example to combine the markers if they are nearby.
Related
I am using here map and I use clustering. But I have problem for displaying maker whose cordinates are same /dublicate . When I zoom in clustering , unfortunately the makers are not visible but cluster is still visible. How to display these makers when cluster is zoomed ?
My clustering options is as following
var clusteredDataProvider = new H.clustering.Provider(dataPoints, {
clusteringOptions : {
eps : 16,
minWeight : 2
},
theme : new PusulaClusterTheme()
});
We had the same issue. If you absolutely need the markers to show the exact very same spot up to the inch so to speak, then I don't know what you could do. But we wanted to show markers for each house on a street and sometimes we had multiple families in a house so we could not get the multiple ones to properly show.
We opened a ticket with HERE and this was their reply:
"...when you are placing multiple markers at the same geo-point, it is
just that they are stacked one on top of the other. Since they are all
at the same coordinate only the top most one will be displayed. So
to enable multiple marker to be shown at the same coordinate, you will
need to have some logic to avoid overlapping of markers. There is no
method straight off the shelf in JS API that can do this for you, but maybe
you can use the method map.getObjectsat(X,Y) to check if there are
already any markers at the point. If there is an existing one, then use
some logic to slightly change the coordinate value of the new marker
to be added at the point.
We ended up copying a solution we found here on Stackoverflow see this link that was written for Google Maps, but is just as relevant here with HERE. It uses a function to randomly change the last digit or 2 of the coordinates if they are multiple, and that way all your multiple coordinates will be a little bit unique and spaced out.
I have a map that members can plot points of interest. I would like to be able to add "disabled" areas on the map that prohibits members from adding points to that area.
Example: If I add a point to the US Capitol, no members can add a point within a given radius of that point.
Is this possible?
Yes you can do this. The way to go about it is keep an array of areas which are not allowed.
You can use polygons, or a point with a buffer, from which you will need to create a circle to check it.
You can do this using the Google geometry api. There is a method to check if a point is within a polygon:
google.maps.geometry.poly.containsLocation(point, polygon)
Then as the user clicks on the map to add anew point of interest, in the click event before adding the marker, check to see if that marker location falls within any of the restricted areas, if so don't add the marker, else add the marker.
Ok, let me preface this question with the fact that I have created a lot of google maps, but they have been strictly markers and polylines denoting routes and a couple with some handler interaction.
Now I am looking to show basically a map of the world, mostly North America and I want to split this continent into my predefined regions with some lats/lngs that I have. Using these regions I want to draw something like a polygon with a light opacity and different color per region.
I then want to use marker clustering but I want the clusters to be specific to these regions. I have looked around but I haven't found an example like this. I have seen pages that say you can do this but not how you would go about doing this. Again, I am definitely a noob when it comes to drawing polygons and using the marker cluster. I know this question is fairly vague but just looking for an example/idea to start off of, and more so I don't want to write a bunch of code against this specific api and then find out that it is not possible.
Any ideas or suggestions are greatly appreciated....Thanks.
It can be done, but will require a rewrite of the MarkerClusterer (probably will simplify it).
You will need to determine how you are going to represent and load the cluster boundary polygons (KML, GeoJSON, native Google Maps API v3 polygons) and probably use the google.maps.geometry.poly.containsLocation(point:LatLng, polygon:Polygon) instead of LatLngBounds.contains to determine which cluster "owns" a marker.
Can anyone share some JavaScript that enumerates all markers in a Google Map?
Need script for v2 and v3 if possible. Thanks.
The only time you have access to the markers and can enumerate them is when they are created. The map has no awareness of what markers are attached to it, and it seems like you want to be able to do it on a map that has been initialised and markers have been added.
In other words, that is not possible. The way to do this is to put the markers into an array while you make them.
I have a scenario where I have to highlight borders and shade a state or city after geocoding it (when I got the lang and lat).
How can I do this, do I need to have a complete information of a city to surround it with polylines? Or is there a way that map API can do this for me.
True. Google does not provide this feature. So what we can do... we can have the lat/long of the borders of the state. And we have to draw polygons ourselves.
I used this JS object. And changed it to Google map object (google.maps.LatLng).
For example:
var statesobj = {"AK": [new google.maps.LatLng(70.0187, -141.0205),
new google.maps.LatLng(70.1292, -141.7291),
new google.maps.LatLng(70.4515, -144.8163)]}
So, it's easy now. Loop on these lat/longs. And you can draw the polygons on every state of US.
So this is the solution I came up. If you guys know some better idea to do it. Please share.
You can also try Google Geo Charts:
http://code.google.com/apis/chart/interactive/docs/gallery/geochart.html
Google Maps API doesn't allow you to retrieve city borders. There are a couple other places from which you can get the coordinates, though:
Flickr API
There is a Flickr API based on photos that people tag, but it's only as accurate as the people who tag photos: so it's good enough for bootstrapping but probably not for production: http://karya-blog.blogspot.com/2012/12/fetching-city-polygons-with-flickr-api.html
Natural Earth Data
An accurate alternative is www.naturalearthdata.com. To get that data from there you just need to make two requests: one with the city name and one with their ID to get the parameters:
unlock.edina.ac.uk/ws/search?name=berlin&gazetteer=naturalearth&format=json
and then
unlock.edina.ac.uk/ws/footprintLookup?format=json&identifier=14126951
and you're set :)
Mapzen
If it's possible for you to pre-fetch the data, go for Mapzen, they have a full and pretty accurate database: https://mapzen.com/data/borders/
I'm afraid google maps API doesn't provide any means to access region (country, state, city, ...) shapes.
If you want to highlight regions you have to create custom overlays based on data acquired elsewhere.
Now the basic map example includes a "mashup" of data. When identifying data is fed to the web service, the resulting output can pinpoint locations on the map.
It shows how a geographic Map Marker is placed on the map to identify a specific location. Map Markers can use the default icon (shown) or a custom image, gauge, or even a chart. Optionally, the map can be configured to display a Map Marker Info window, containing additional location-specific data, when the marker is clicked.
It includes data-driven, colored regions (in this case, representing postal codes) overlaid a map of eg Washington, DC. Logi Info can work with GIS boundary data to produce region overlays for states, counties, cities, school districts, and other areas. Like the Map Marker, regions can be clicked to display a pop-up information window with detail data.