Real-Time update of markers in google maps? - google-maps

thats my scenario: I want to load a list of places of interest of a user based on his location (using HTML5 geolocation). But the problem is, I have a very big list of places (I don't want to have to load all places from my database), so the solution I have adopted until now is only to call mysql for the results in a given radius from the user, let's say, 1 km. But I'd like when user is dragging google maps to explore the map, load progressively the places for the area is shown on the map (basically something similar to what foursquare does).
Is there any simple way to achieve that? Hope I was clear with the question, thanks in advance, any help is appreciated.
Jesús.

General approach:
get the bounds of the map and query your data base for markers that are currently in view
optional, add padding to the bounds so some markers are available just out of view if the map is dragged
display the resulting markers
when the map is moved (bounds_changed event), query your database for additional markers
process through the returned markers, only adding those that are new (requires an array of existing markers and a way to determine that the existing marker and a newly downloaded marker are the same)
Searching the Google Maps API v3 group (and the Google Maps API v2 group, the concepts will apply but the code samples may not) should give you some examples.

Related

Google Maps Api - newbie

I am starting to work on a Google Maps project, but I am totally new to Google Maps Api, as well as my JavaScript skills are quite small, my background is Java. I have started reading throught the docs and tutorials, but some basic questions stay unanswered, so I hope to get some help from you.
Does Google Maps api provide a way for user access control? Lets say, I have a map where my registered users(Joomla site) can add placemarks, how do I tell Google Maps if this user is allowed to work on the map? Or do I have to take care of that by myself without the Maps API?
What would be the right approach to create the following functionality: I want to let a user add a placemark to an empty map. Then I will check if the point added is ok for public publishing. If it's ok, then I want to transfer that placemark to the public map.
Is there some Maps API function to read out the placemarks on a specific map?
Andy
Regarding the user access control, it seems that I have mixed two things. When you use Google Maps on Google website, and you create your map with markers, you can specify other users who are allowed to add and edit markers on that map. However, Google Maps api obviously does not save a server side copy of the map you are working on. So everything happens at your site. If you add markers, then you have to keep track of them by yourself, so also user access control is your own problem.
However, I wonder, what would happen when I would create my own map on the Google Maps website with my own markers, and then I would display this map on my site. What would be then the way to read out the markers, lets say for a list of markers.
It seems that the right way is to implement it all yourself. Let user set marker, save the marker in database. Review the marker and if accepted mark it and display it on the public map when populating the map with your markers.
Ok, so I've been reading around and I found out, that obviously Google Maps does not provide a function to read out all markers on a map: how to get all markers on google-maps-v3

Is it possible to put a location marker on a google map without requesting it from the google server?

Really quick/simple question that will determine which map API i use for my project.
I dont need an example- ill figure that out, i just need to know if the capabilities are there.
If i have store geocode (latitude, longitude) coordinates in a database, can i put one of those little red markers on a google map without having to actually make a geocoding request from google?
Additional question:
Also, would it count towards any quotas every time i display one of their maps, even if i give them the geocoded coordinates? Because i mean technically their map still has to find those coordinates...
Q1: Yes — you tell the API the coordinates of where to put the marker, rather than get Google to find those coordinates.
Q2: The usage limits are published by Google. You can have up to 25000 map loads per day. If you don't use the geocoder because you provide the coordinates yourself, then you don't use a geocoder access.

Google Maps Android - set too many markers

My question is, What is the best way to set to many markers on google maps on android program? I have a sqlite database with longitude and latitude for every markers.
For example add all markers 1km around the current location
Get the range of longitude and latitude on moving map and display markers between that range
How can i get the range of longitude and latitude?
Based on the comments from above you will need to do the following:
1) Use the Google Api maps reference for Android to determine the visible area on the map and if one of your points is within the determined area.
2) Carefully remove points added to the map but which are no longer needed. (IE the user has moved the map). Be careful at this point not to remove a point before the map has finished updating, as the user could tap on a point and crash the app.
3) Decide what you're doing about zoom level, if a user zooms right out then you need to do one of the following:
a) Display nothing, give the user feedback to zoom in for points.
b) Use an algorithm to plot a point at an average of a point.
c) Display a marker as with b but centered in a region with the number of points in that region.
I would advise lots of research on stack regarding previous questions as this topic has been covered in some detail.
For c) there has been a good iOS implementation which is now a for-sale library, however the name of the library escapes me at the moment. I am told the implementation is excellent.
I cannot express enough that you need to make sure your map operations are done asynchronously, be wary of this or fall into lots of traps.

Google Maps - Places library - Search for custom placed markers in radius

I'm developing a app that makes use of the Gmaps Places library and actually, I have two questions:
1) Does anyone know how long it takes to an added place(by POST request) to show up on the map? I only need it on the app's map, so I don't care if Google doesn't approve it. I've already sent the add request and received OK as response.
2) It is possible to search for markers, placed by me, as if they were places(and using radius)? Not necessarily using the Places library. I ask this to see if is possible to come with a backup plan if the waiting mentioned above is long(clients, clients...). Then I would have the places 'offline from Gmaps', mapped inside a JSON file.
If I understand you correctly, you want to combine Google's Places API with a custom location set? Without more detail I can't really tell you what the code would look like, but you'd basically want to mash up the results you get from places with your own data and place markers based on that merge. If you're searching by radius or polygon you can do a 'within bounds' search on your dataset and return any results that are within the search zone to feed into your marker creator.

Google Maps Store Locator Search field for embedded map

I've embedded a map on a clients site, with their various store locations, using the google saved maps technique: http://passportal.com.au/stockists So basically I don't want store the marker locations in a database, I'm just interested in using the marker positions on the saved map as seen in this demo: http://maps.google.com/help/maps/getmaps/plot-multi.html
I've seen it on plenty of sites and am wondering if there is an easy way to add a search field to find the closest marker to the users address. Something like this: http://www.victoriantextiles.com.au/store-locator
The closest I could find was a google gadget that allows you to type in directions: http://www.google.com/ig/directory?synd=open&hl=en&gl=en&url=http://igwidgets.com/lig/gw/f/islk/89/slkm/ik/s/1329844/87/charles447/google-maps-driving-directions.xml
Any help would be great, thanks!
For this purpose, I use Google Maps API Distance Matrix where I would pass in one origin - user's location and multiple destinations - our dealers. Then I sort the results by distance and take 3 closest to display in a list. Works pretty fast, however, I don't know how you'd achieve this without having some sort of database of your store addresses.