More

Using Google Maps API v2 and Maps engine?

Using Google Maps API v2 and Maps engine?


I am researching on the options in drawing shapes on Google Maps with API v2 and Google Maps Engine. I have managed to set up the admission to draw a viewed layer on my setup on my site.

Does anyone know if it is possible to access your own layers and maps and draw an save the tables with attributes and so on?


I would not use Google API v2, as it is deprecated: https://developers.google.com/maps/documentation/javascript/v2/v2tov3 For version 3 see https://developers.google.com/maps/documentation/javascript/shapes Google maps engine will also be deprecated soon: http://www.appgeo.com/blog/life-google-maps-engine-positive-disruption/

Saving your data could always be done with something like php if there don't exist examples doing that yet. Is there any particular reason why you don't want to use OpenLayers or Leaflet instead?


For targeting api-23 and higher:

For targeting api-22 and lower:

It's actually quite simple, using the FusedLocationProviderAPI is recommended over using the older open source Location APIs, especially since you're already using a Google Map so you are already using Google Play Services.

Simply set up a Location Listener, and update your current location Marker in each onLocationChanged() callback. If you only want one location update, just un-register for callbacks after the first callback returns.


Android Application to Find Nearby Places using Google Places

The following example application first gets the current location and shows the Google map accordingly. Then based on user input the type of geographic location that needs to find is done. Example for keywords to find using the Google Places API are atm, hospital, airport, bank, etc.

Prerequisite

Google Play Services is required for Google Maps and Google Places. If you are using Android Studio and Gradle, you should have the following dependencies added in build.grade file.

AndroidManifest.xml

Note the following permissions to be given for the app. The API_KEY specified here in the manifest is for Google Maps.


Storing and retrieving locations in SQLite from Google Maps Android API V2

In this article, we will develop an Android application which demonstrates how to store and retrieve Google Maps locations in SQLite database from Google Maps Android API V2.

On taping a location in the Google Map, a marker will be drawn at the taped location and the corresponding coordinates with Google Map zoom level will be saved in SQLite database. On restarting the application, the saved locations are retrieved from the SQLite database and redrawn in the Google Maps.

In this application, the database is accessed via Content Providers. The insertion and deletion operations are executed in non-ui thread using AsyncTask objects and the data retrieval is done using CursorLoader.

This application is developed in Eclipse (4.2.1) with ADT plugin (21.1.0) and Android SDK (21.1.0) and tested in a real Android device (Android 2.3.6 - GingerBread).

1. Create a new Android application project namely “LocationMarkerSQLite”

Figure 1 : Create an Android application project

2. Configure the project

Figure 2 : Configure the application project

3. Design application launcher icon

Figure 3 : Design application launcher icon

4. Create a blank activity

Figure 4 : Create a blank activity

5. Enter MainActivity details

Figure 5 : Enter MainActivity Details

6. Download and configure Google Play Services Library in Eclipse

Google Map for Android is now integrated with Google Play Services. So we need to set up Google Play Service Library for developing Google Map application in Android.

Please follow the given below link to setup Google Play Service library in Eclipse.

7. Add Google Play Services Library to this project

Figure 6 : Link Google Play Services Library to this project

8. Get the API key for Google Maps Android API V2

We need to get an API key from Google to use Google Maps in Android application.

Please follow the given below link to get the API key for Google Maps Android API v2.

9. Add Android Support library to this project

By default, Android support library (android-support-v4.jar ) is added to this project by Eclipse IDE to the directory libs. If it is not added, we can do it manually by doing the following steps :

  • Open Project Explorer by Clicking “Window -> Show View -> Project Explorer”
  • Right click this project
  • Then from popup menu, Click “Android Tools -> Add Support Library “

10. Update the layout file res/layout/activity_main.xml

11. Create a table class in the file src/in/wptrafficanalyzer/locationmarkersqlite/LocationsDB.java

12. Create content provider class in the file src/in/wptrafficanalyzer/locationmarkersqlite/LocationsContentProvider.java

13. Update the class “MainActivity” in the file src/in/wptrafficanalyzer/locationmarkersqlite/MainActivity.java

14. Update the file AndroidManifest.xml

Note : Replace “YOUR_ANDROID_API_KEY” with the Android API key obtained in Step 8.

15. Executing the application

In Eclipse IDE, we can execute the application from the menu “Run -> Runs As -> Android Application

Figure 7 : Screenshot of the application in execution

16. Download the source code

I am George Mathew, working as software architect and Android app developer at wptrafficanalyzer.in

You can hire me on hourly basis or on project basis for Android applications development.

For hiring me, please mail your requirements to [email protected]

Ready to test your knowledge in Android? Take this quiz :


49 Responses to Storing and retrieving locations in SQLite from Google Maps Android API V2

I have downloaded this code and did everything that mentioned above.but while launched the app.it stopped unfortunately………..help.

Are you getting any hint in Logcat regarding the error occurred while launching the app?

04-24 11:05:29.523: E/AndroidRuntime(774): FATAL EXCEPTION: main
04-24 11:05:29.523: E/AndroidRuntime(774): java.lang.RuntimeException: Unable to start activity ComponentInfo: android.view.InflateException: Binary XML file line #7: Error inflating class fragment
04-24 11:05:29.523: E/AndroidRuntime(774): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2059)
04-24 11:05:29.523: E/AndroidRuntime(774): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
04-24 11:05:29.523: E/AndroidRuntime(774): at android.app.ActivityThread.access$600(ActivityThread.java:130)
04-24 11:05:29.523: E/AndroidRuntime(774): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
04-24 11:05:29.523: E/AndroidRuntime(774): at android.os.Handler.dispatchMessage(Handler.java:99)
04-24 11:05:29.523: E/AndroidRuntime(774): at android.os.Looper.loop(Looper.java:137)
04-24 11:05:29.523: E/AndroidRuntime(774): at android.app.ActivityThread.main(ActivityThread.java:4745)
04-24 11:05:29.523: E/AndroidRuntime(774): at java.lang.reflect.Method.invokeNative(Native Method)
04-24 11:05:29.523: E/AndroidRuntime(774): at java.lang.reflect.Method.invoke(Method.java:511)
04-24 11:05:29.523: E/AndroidRuntime(774): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
04-24 11:05:29.523: E/AndroidRuntime(774): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
04-24 11:05:29.523: E/AndroidRuntime(774): at dalvik.system.NativeStart.main(Native Method)
04-24 11:05:29.523: E/AndroidRuntime(774): Caused by: android.view.InflateException: Binary XML file line #7: Error inflating class fragment

=> Uninstall this application from your Android device

=> Clean this project ( In Eclipse IDE, use the menu Project -> Clean … )

=> Run the application ( In Eclipse IDE, use the menu Run -> Run As -> Android Application )

I follow your instruction already…but still same the error…
Can I ask how to track user location and draw the route path when user move.
Thank you very much first

I had the same issue and had to add SupportMapFragment to the XML

it is worked?? please tell me how to add SupportMapFragment to the XML

i’m also having the same errors.plz tell me how can i remove it.

thank for your work
christophe

Hello, well the initLoader has an error for me,
The method initLoader(int, Bundle, LoaderManager.LoaderCallbacks) in the type LoaderManager is not applicable for the arguments (int, null, MapsActivity).

How can I solve this!? pleasee

Hello Marilia,
Please ensure that, the class MainActivity is importing “android.support.v4.app.LoaderManager.LoaderCallbacks”.

Ok now I run it but the problem seem to be on the database, and the problem is in the getAllLocations() funtion.

05-07 18:39:10.099: E/AndroidRuntime(15828): Caused by: java.lang.NullPointerException
05-07 18:39:10.099: E/AndroidRuntime(15828): at com.appproyecto.DBAdapter.getAllLocations(DBAdapter.java:219)
05-07 18:39:10.099: E/AndroidRuntime(15828): at com.appproyecto.LocationContentProvider.query(LocationContentProvider.java:81)
05-07 18:39:10.099: E/AndroidRuntime(15828): at android.content.ContentProvider$Transport.query(ContentProvider.java:187)
05-07 18:39:10.099: E/AndroidRuntime(15828): at android.content.ContentResolver.query(ContentResolver.java:262)
05-07 18:39:10.099: E/AndroidRuntime(15828): at android.support.v4.content.CursorLoader.loadInBackground(CursorLoader.java:49)
05-07 18:39:10.099: E/AndroidRuntime(15828): at android.support.v4.content.CursorLoader.loadInBackground(CursorLoader.java:35)
05-07 18:39:10.099: E/AndroidRuntime(15828): at android.support.v4.content.AsyncTaskLoader.onLoadInBackground(AsyncTaskLoader.java:240)
05-07 18:39:10.099: E/AndroidRuntime(15828): at android.support.v4.content.AsyncTaskLoader$LoadTask.doInBackground(AsyncTaskLoader.java:51)
05-07 18:39:10.099: E/AndroidRuntime(15828): at android.support.v4.content.AsyncTaskLoader$LoadTask.doInBackground(AsyncTaskLoader.java:40)
05-07 18:39:10.099: E/AndroidRuntime(15828): at android.support.v4.content.ModernAsyncTask$2.call(ModernAsyncTask.java:123)
05-07 18:39:10.099: E/AndroidRuntime(15828): at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:306)
05-07 18:39:10.099: E/AndroidRuntime(15828): … 4 more

hello
i do it but i have a probleme
the number of marker read isn’t the same when i read the sqlitedata

when i reload the activity
(1900 marker stored checked ok well stored)
when i do the activity sometime 530 marker showed
sometime 280, sometime 1900

thank for your help
Christophe

hello i dont know how to do, can you help me
i store in data bvase the good number of data
but when i read it, it does’n read the same number of data??

hi… nice tutorials. i need your help in my project. i am using sqlite database and want to retrieve values on the map in form of overlay. you used here content provider etc my sqlite database is designed with ADAPTER class. please help me..
thanx

Thanks for the sharing. But, now, I am facing a problem. I have several thousand rows in the sqlite. When I load the data at once and I touched the screen, it will show “the app is not responding” either “wait” or “close”. Do you know what problem cause this issue?

Are you sure, you are retrieving the data in a non-ui thread.

I run AsyncTask in onLoadFinished. loop through the data in doInBackground and store them into ArrayList. Finally, pass ArrayList to onPostExecute and loop through the ArrayList to addMarker on maps. Am I do right?

your tutorial is very very good..i like it….i have one question i added name column with this database and i am getting that name in spinner…what i want to do when i click on spinner item that time i want to redraw location for that perticular saved name from sqlite to map……plz suggest me how i do this……..

1. Get the selected item name in itemclick listener of the spinner.
2. With this name, you can fetch corresponding latitude , longitude pair from the sqlite database using ContentProvider in asynchronous mode.
3. Draw the coordinate in the map.

but i am not getting can i send u source code so please correct them….i know i am doing some silly mistakes but please help me

hi there
thanks for all of this… its amazing

i am kind of new to all of this stuff….
what steps should i take to be able to launch this app? i dont have sqlite on my computer. after i download it – what should i do? how do i make this app talk with it?

* After downloading, extract the zip file
* Import the extracted folder into your eclipse, which is already configured for Android app development
* Run the application as Android Application
* Then the application will be executed in the Android device connected to your machine

Note : You don’t need any sqlite database in your computer. Sqlite database will be already there in the Android.

sorry i don’t understand metode above

i want to save 15 markers on the database SQLite and they can just added by me (only admin, the user can’t add marker), please tell me how to do it.


Important Note:

  • To use Google Maps in PRTG Network Monitor version 13 or later, you need to acquire a new API key for Google Maps API v3!
  • Important: You have to Enable the Static Maps API in the Google API Console's settings!
  • You have to run your PRTG web server as Secure HTTPS server to use Google Maps. By default, PRTG version 18.3.42 and later uses the geocode of HERE Maps, because Google will forbid a keyless access to the geocoding API in future. Geocoding is used to convert the addresses that you enter in the Location (for Geo Maps) settings into geographic coordinates to show the position of your monitoring objects on the geo map.
    If you still want to use the geocoding API of Google, you have to enable your Maps Static API access key for the Geocoding API as well.

We recommend that you do not use Google Static Maps! If you use this option, Geo Maps will be shown with limited functionality.

Step 1: Get a Google account

First you need a Google account. If you do not have one, you can create one here: https://accounts.google.com/NewAccount

Step 2: Use the Google APIs console to create your key

Important: As of PRTG version 13, use the Google Maps API v3 service. See above.

  1. Open the Google APIs console and log in: https://console.developers.google.com
  2. Create a project or open an existing one.
  3. Open the API Library to show all Google APIs.
  4. In the section Maps, click Maps Static API (you might have to expand the list with View all to see the entry).
  5. Click Enable to use the Google Maps Static API.
  6. Open the Credentials tab and click Create credentials. Use the option API key.
  7. Do not restrict the key (None) or provide the domain of your PRTG installation. For example, get it from the URL of your PRTG installation: https://<provide this part>/group.htm?id=0&tabid=1
  8. Copy your API key.

Note: To use the Google Geocoding API instead of the HERE Maps geocoding in PRTG version 18.3.42 or later, additionally enable Geocoding API in the Google console and use the API key that you generated for the Maps Static API before.

Step 3: Enter API key in PRTG

  1. Copy your API key from the Google page.
  2. In the PRTG web interface, select Setup | System Administration |User Interface ("System & Website" in previous versions) from the main menu.
  3. In the Geo Maps (Google Maps Integration) section, select one Map Type and paste your API key into the API Key (required) field.
  4. Save your settings.

Step 4: Switch web server to SSL

Geo Maps can only be shown if the PRTG web server runs using HTTPS on port 443. To apply this setting, open Setup | System Administration | User Interface from the main menu bar in the PRTG web interface. In the section Web Server, switch the TCP Port for Web Server to Secure HTTPS server (Port 443), click Save, and confirm the restart of the Windows services.

From now on, PRTG will show the location of groups and devices in maps if there is respective location information available in the Objects Settings. No Geo Maps will be displayed if you do not provide location information in PRTG!

Optional: Delete browser cookies

If you still do not see Google Maps in the PRTG web interface, please delete all cookies in the browser you use to access the web interface, or use a different browser.

To learn more about the Maps API, see the FAQ section of Google.

Google maps will not work in deprecated PRTG versions 7 through 9.2.0.2175! Please update PRTG to the current version.

Last change on Dec 4, 2020 3:02:14 PM by Brandy Greger [Paessler Support]


How to make a location-based app: A step-by-step guide

Creating a location-based app is a systematic plan that involves several stages, including testing, research, wireframing, and consumer outreach. This well-structured process focuses on identifying the main factors that enable your business to maintain market dominance.

Let&rsquos go through some of the key factors and steps involved in creating a location-based app.

Step 1. Research Your Idea

The business analysis offers insights into current consumer trends to be considered when developing an app. Don&rsquot forget to analyze your competition to enhance your set objective.

Also, arrange every finding with a story map based on priority and complexity. These techniques are efficient when sharing insights on every given task within the ideation chain.

Which location-based service is in demand? How will the app address users&rsquo requests?

If you don&rsquot address the issues before developing a location-based app, you will struggle to create an application with market relevance and quality.

Therefore, research the market and competitors to look at the market potential and figure out how to make the app better.

Step 2. Create a Wireframe of your geolocation app

UX app design and wireframing are essential for location-based app development. You always want to visualize the app on a screen and fix possible functionality issues before the app goes into the development stage.

To bring your idea to reality, you and your app development team need to put your idea down on paper and develop a storyboard. Subsequently, the storyboard, wireframes, and mockups will help to determine the geolocation app&rsquos potency and market performance.

Step 3. Prove GPS app concept with MVP

A proof of concept (MVP) is essential for developing location-based apps. This proof of principles shows that the app may become a viable product. Therefore, create a minimum viable product for your business idea. This concept will help you to target any reliable source of investment. Similarly, you can give the public the chance to know the project&rsquos objective.

Step 4. Create a feature-rich map-based app

After receiving user feedback, you can start the second development stage and add other important features to your app. Always pay special attention to consumer concerns and suggestions.

For location-based apps, the main features should always provide the best advice on objects within a given radius. Remember to add the account creation function and other basic features.

You can add extra steps to address issues like marketing and sales, but these four key tips are indispensable when working on a geolocation app.

By following these procedures, you will build a location-based app with high ratings. And soon enough, you can start competing with the best software companies in the world.


About the New York Genealogical and Biographical Society


The New York Genealogical and Biographical Society is
a registered 501(c)(3) organization devoted to
preserving, documenting, and sharing the history of
New York State families. Read more about our mission.

Since 1869, our mission has been to help our thousands of worldwide members discover their family's New York story, and there has never been a better time to join.

The cost of an Individual Annual Membership is less than six dollars a month, and includes the following benefits:


Find anyone’s location from their router MAC address (Google Maps API exploit)

These days location based services can tell where you are at any time. Many online services can pretty much tell your location but they don’t generally pinpoint it at the exact GPS co-ordinates. Samy Kamkar has used the undocumented Google Maps API to map a web browser to GPS coordinates via router XSS and Google’s Location based services i.e. using this, one can find the location of any person from their MAC address. The application is called MapXSS.

The router and web browser themselves contain no geolocation/GPS data and is also not IP based Geolocation. This works via Router XSS which obtains the MAC address of the router via AJAX. The MAC address is then sent to the person who is trying to learn your location. The MAC address is then sent to the Google’s Location Based Services which can map the location (approximate GPS co-ordinates) of a user based on his MAC address. The creator of MapXSS says that he determined this protocol by using Firefox’s Location Aware Browsing.

Without Google Maps, this method of knowing one’s location through XSS exploit isn’t possible. Google while collecting data for the Google Street View had also collected data of the wireless networks in the vicinity and the MAC address of those routers. and then mapped them to the GPS co-ordinates. A malicious page you’re visiting might perform an XSS exploit and retrieve the MAC address of your router and then retrieve the GPS co-ordinates corresponding to that MAC address from Google Maps.

This exploit is a really serious thing and it can cause serious crimes as thugs and ruffians can easily know your location.


For Genealogists

Google Maps makes it easy to locate places, including small towns, libraries, cemeteries, and churches. It is important to note that these are not historic listings, however. Google Maps draws its locations from current map and business listings, so the cemetery listings, for example, will generally be larger cemeteries that are in current use.

To create a Google Map, you begin by selecting a location. You can do this through search, or by dragging and clicking. Once you've found the location you want, then switch to the "find businesses" tab to pinpoint churches, cemeteries, historical societies, or other points of interest.


5 Answers 5

  1. Go to API Manager
  2. Click on Overview
  3. Search for Google Maps JavaScript API (Under Google Maps APIs ). Click on that
  4. You will find Enable button there. Click to enable API.

OR You can try this url: Maps JavaScript API

Hope this will solve the problem of enabling API.

Assuming you already have a application created under google developer console, Follow the below steps

  1. Go to the following link https://console.cloud.google.com/apis/dashboard? you will be getting the below page
  2. Click on ENABLE APIS AND SERVICES you will be directed to following page
  3. Select the desired option - in this case "Maps JavaScript API"
  4. Click ENABLE button as below,

Note: Please use a server to load the html file

as of Jan 2017, unfortunately @Adi's answer, while it seems like it should work, does not. (Google's API key process is buggy)

also I strongly recommend you don't ever choose "secure key" until you are ready to switch to production. I did http referrer restrictions on a key and afterwards was unable to get it working with localhost, even after disabling security for the key. I had to create a new key for it to work again.


Watch the video: Google Maps Developers Live: Google Maps Android API V2