Disable Adding Markers to Certain Areas of a Map - google-maps-api-3

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.

Related

Here map does marker belong to cluster?

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.

How to display duplicate maker in cluster here map

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.

How to know If marker crossed polygon on google map

I am trying to locate the iPad location. Where as goal is to get alert when user who carrying the iPad should be inside polygon always. How to get alert if provided latitude and longitude crossing the polygon. Any reference link ?
You could use geofence,put a circle on the map set radius and give a condition if its out give a alert.

Google Maps API Display icon along route at a specific distance from start

I want to display virtual progress on a Google map.
I want to display a map with a route and on that route I want to display an icon at some distance (that will be computed based on data) from the start. That distance could change from moment to moment or day to day depending on the data related to the progress along the virtual route.
For instance on a route from LA to NY, one day I may want to display an icon at 772 miles from the start. The distance along the route can be in units or as a percentage.
I have seen the google.maps.IconSequence object, but can't see how to use that with DirectionsService.
A couple of "mile marker/kilometer marker" examples and an animated marker:
every 2 km
2 markers at specific distances along a route
An animated marker along a route

Highlighting borders of state and cities of US in Google Map API 3

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.

Resources