I tried everything but whatever I do static Google map is now showing more than 5 pins.
My static map URL is https://maps.googleapis.com/maps/api/staticmap?center=43.508708883,16.439189110&zoom=7&size=640x320&key=MY_API_KEY&markers=icon:http://test2018.adriagate.com/images/pin-number-icon-1.png?v=7|43.508708,16.439189&markers=icon:http://test2018.adriagate.com/images/pin-number-icon-2.png?v=7|43.172360,16.441608&markers=icon:http://test2018.adriagate.com/images/pin-number-icon-3.png?v=7|42.787800,17.345000&markers=icon:http://test2018.adriagate.com/images/pin-number-icon-4.png?v=7|42.650600,18.091400&markers=icon:http://test2018.adriagate.com/images/pin-number-icon-5.png?v=7|42.958300,17.134400&markers=icon:http://test2018.adriagate.com/images/pin-number-icon-6.png?v=7|43.296700,17.017800&markers=icon:http://test2018.adriagate.com/images/pin-number-icon-7.png?v=7|43.444400,16.688300&markers=icon:http://test2018.adriagate.com/images/pin-number-icon-8.png?v=7|43.508708,16.439189
It seems it is short enough because limit is 2048 characters. It has only 8 pins. There is only limit is markers if it has adress instead of latitude and longitude.
I lost few hours and whatever I do it is not showing pin 6 7 and 8.
Yes, they exist on server as you can see:
http://test2018.adriagate.com/images/pin-number-icon-8.png
This is a documented behavior of Static Maps API.
Have a look at this page
https://developers.google.com/maps/documentation/maps-static/dev-guide#Markers
There is the following statement
You can use up to five unique custom icons per request. This limitation does not mean that you are limited to only 5 marked locations on your map. Each unique icon may be used with more than one markers location on your map.
There was also feature request in Google issue tracker to allow more than 5 unique icons:
https://issuetracker.google.com/issues/35825584
However, Google marked this feature request as duplicated in favor of another feature request regarding KML layers in static maps:
https://issuetracker.google.com/issues/35817020
Feel free to star the feature request to express your interest.
I hope my answer clarifies your doubt.
Related
I want to use Google place autocomplete webservice: https://developers.google.com/places/web-service/autocomplete
to search for locations based upon a query (e.g. "High Street"). I also want the latitude and longitude of each place.
It seems that the only way to do this using the web service is to:
Perform an autocomplete search e.g.
https://maps.googleapis.com/maps/api/place/autocomplete/json?input=Vict&types=(cities)&language=en_GB&key=YOUR_API_KEY
Loop through each result and do a separate query for each location (see https://developers.google.com/places/web-service/details):
https://maps.googleapis.com/maps/api/place/details/json?placeid=PLACE_ID&key=YOUR_API_KEY
That means if I have 10 results, I have to do 10 additional web requests! That means 11 in total (1 for autocomplete, and 10 more for each place request).
This is very inefficient!
Surely there is a better way than this, as Google Maps on Android shows the distance of each place to your current location, indicating that the latitude and longitude is returned as shown by this screenshot:
Yes, for Places API, Directions API and Geocoding API that is the case. There is no other way.
you can use this API
of google APIs
https://maps.googleapis.com/maps/api/geocode/json?address=Winnetka&key=YOUR_API_KEY
I am developing GPS based Location reminder in j2me. I am little bit confuse to which maps i use??.....Google maps & Nokia maps. Which one allows me good working... The working of my app are as follows :-
-User will provide a string to app to search a place of his/her desire.
-Then according to given string app will show a place on map by pointing marker on map.
-User can save that place or he/she can select a near by place rather than searched place by clicking on map or any other way.
-app will save that searched place coordinates & remind when it reached to near that place.
-When app remind to user about already stored place... that place should show on map by pointing an marker along with the how far he is from his destination.
The real choice here lies in whether to use a RESTful API like the Google Static Maps (or Nokia's RESTful Maps) or to use a native Java ME mapping library plugin such as the Nokia Maps API for Java ME. The latter has several major advantages:
Static mapping services such as the Google Static Maps API or Nokia's
RESTful Map API do not cache or tile the images when requested,
therefore each request involves a round trip to the server. If the
map on a mobile application needs to be refreshed at any time, using
a caching library will result in a reduction in network traffic after
around three maps have been displayed. An explanation of this can be
found here
As the name implies, Google's Static Maps API can only retrieve over
http static images for a requested coordinate point, image size,
image type and zoom level. Newer libraries offer additional
functionality out of the box offering dynamic Map content and touch
support, where the user can move around his/her current position,
zoom in, zoom out, modify the view mode to satellite or translate an
address to a coordinate point and show that on the map, among others.
This abstraction of the underlying functionality is hidden from the
developer so much less coding is needed in order to achieve the same
result .
Terms and Conditions for Nokia Maps are easier to fulfil than
Google - No legal restrictions of using the API outside a web browser
application or need to provide a link to the native Google Maps App
(if there is one), or to Google Maps (if there isn't one).
Nokia currently offer higher free daily request limits. Nokia Maps
API for Java ME supports up to 50,000 render requests per day and per
unique IP address (as of January 2012), for Nokia Developer
registered users (free of charge) while the limit for Google's Static
Maps API is currently 1000 unique (different) image requests per
viewer per day.
A couple of years ago there wouldn't be a choice, only RESTful solutions existed, but these days I would say a static http solution should only be used if you want a simple single image
As an abstraction of the underlying services, there are already a full set of examples to cover most of your use cases:
-User will provide a string to app to search a place of his/her desire.
-Then according to given string app will show a place on map by pointing marker on map.
http://www.developer.nokia.com/Commu...PI_for_Java_ME
-User can save that place or he/she can select a near by place rather than searched place by clicking on map or any other way.
Maybe you need to use a draggable marker:
http://www.developer.nokia.com/Devel...ples/#standard
Or react to the touch and find a Geocoordinate:
http://www.developer.nokia.com/Commu...PI_for_Java_ME
-app will save that searched place coordinates & remind when it reached to near that place.
This is known as geofencing and is covered by the Location API:
- http://www.developer.nokia.com/Resou...ty-events.html
-When app remind to user about already stored place... that place should show on map by pointing an marker along with the how far he is
from his destination.
Showing a Map with a Marker
http://www.developer.nokia.com/Devel...ples/#standard
For distance calculations, I guess you'd be after the ROUTING example
http://www.developer.nokia.com/Devel...mples/#routing
http://www.developer.nokia.com/Commu...g_with_Java_ME
Now you could re-write and all these services from scratch using RESTful APIs (and then go about debugging your code) , but I'm sure you'll agree it would be much easier to use an existing, working and tested framework for the low level plumbing and then just write your code on top using the services.
It is possible to encapsulate RESTful service in Java ME. As an example, added below is a screenshot from an app encapsulating the suggestion service
It is just a lot easier when someone else has already done this work for you and placed it in a library.
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.
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.
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.