Giter VIP home page Giter VIP logo

anymaps's Introduction

AnyMaps

Build status

AnyMaps allows you to use the same API for different maps providers without the need to adjust existing Google Maps implementation (apart from changing the package name).

We are relying on this library in car2go to allow customers without Google Play Services to use our product.

Features

  • Does not depend on any map provider - you can even use it without Google Maps.
  • Map provider can be changed at runtime.
  • Easy to extend. New providers can be added without changing the existing code.
  • Map providers supported out of the box: Google Maps, OpenStreet maps, Baidu maps.

Add it to your project

Step one

Add jitpack.io to list of your repositories.

repositories {
  maven { url 'https://jitpack.io' }
}

Step two

Choose which kinds of maps you want to use and add the latest version to your project.

// Required for all projects
compile 'com.github.car2go.AnyMaps:anymaps-base:x.y.z'
 
// [Optional] Google Maps
compile 'com.github.car2go.AnyMaps:anymaps-google:x.y.z'
compile 'com.google.android.gms:play-services-maps:x.y.z'
 
// [Optional] OpenStreet maps
compile 'com.github.car2go.AnyMaps:anymaps-osm:x.y.z'
 
// [Optional] Baidu maps
compile 'com.github.car2go.AnyMaps:anymaps-baidu:x.y.z'

Depending on the maps which you choose you will need to add API keys to your AndroidManifest (the same way as you would do it without using AnyMaps). For example, for Google Maps it would be:

<application>
    
    <meta-data 
        android:name="com.google.android.geo.API_KEY" 
        android:value="Your API key"/>
    
</application>

Step three

Add view to your layout.

<!-- There is a MapView implementation for each kind of Map. This example shows Google Maps. -->
<com.car2go.maps.google.MapView
        android:id="@+id/map_view"
        android:layout_width="match_parent"
        android:layout_height="match_parent"/>

And then call onCreate, onResume, onPause, onSaveInstanceState, onDestroy and onLowMemory in your Activity. Check the example app for more details.

And you are good to go!

License

Copyright 2017 car2go group GmbH

Released under the MIT license.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

anymaps's People

Contributors

diolor avatar dmitry-zaitsev avatar mauin avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

anymaps's Issues

I got on error upon running the app

Good day, I have tested this project and it doesn't work on me, It gives me this error: (The code is base on the Example + my google API key)

05-04 11:39:48.256 10321-10321/? E/AndroidRuntime: FATAL EXCEPTION: main
Process: bluenergyfuel.testmap, PID: 10321
java.lang.RuntimeException: Unable to start activity ComponentInfo{bluenergyfuel.testmap/bluenergyfuel.testmap.MainActivity}: android.view.InflateException: Binary XML file line #9: Binary XML file line #9: Error inflating class com.car2go.maps.google.MapView
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2680)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2741)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1488)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6176)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:888)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:778)
Caused by: android.view.InflateException: Binary XML file line #9: Binary XML file line #9: Error inflating class com.car2go.maps.google.MapView
Caused by: android.view.InflateException: Binary XML file line #9: Error inflating class com.car2go.maps.google.MapView
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.car2go.maps.google.MapView" on path: DexPathList[[zip file "/data/app/bluenergyfuel.testmap-1/base.apk"],nativeLibraryDirectories=[/data/app/bluenergyfuel.testmap-1/lib/arm64, /system/lib64, /vendor/lib64]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
at java.lang.ClassLoader.loadClass(ClassLoader.java:380)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
at android.view.LayoutInflater.createView(LayoutInflater.java:609)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:787)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:727)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:858)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:821)
at android.view.LayoutInflater.inflate(LayoutInflater.java:518)
at android.view.LayoutInflater.inflate(LayoutInflater.java:426)
at android.view.LayoutInflater.inflate(LayoutInflater.java:377)
at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:292)
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140)
at bluenergyfuel.testmap.MainActivity.onCreate(MainActivity.java:17)
at android.app.Activity.performCreate(Activity.java:6679)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1118)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2633)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2741)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1488)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6176)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:888)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:778)

how to set the title of Pin

when we locate pin on map..
it is not only the icon bitmap
it could be the title text below or a above the icon
How can we add it to the pin?

markers

How to add a lot of markers?thanks

geofence

Why did not you see the concrete way to achieve the geo-fence?

AddCircle on OSM Map seems not work

I have a OSM Map and to add Circle i use the code below

anyMap.addCircle(new CircleOptions().center(new LatLng(0,0)).radius(1000).fillColor(R.color.colorAccent));

But there's no circle in this LatLng position.
I'm doing something wrong or it's a bug?

I've tried the same way the other types of overlay (polygon, polyline,...) and only Marker seems to work.
Any idea why or what can i do to fix this?

Changing map types

When I build the example app it appears to be using google maps.

What changes do I need to make to use OSM map. Is there an example of this.

How to clear map?

Hi, using anymaps-osm I noticed that clear() method is not implemented. Is it possible to remove the markers from map?
Thanks

Marker on OSM Maps seems at wrong place at low zoom

When i make a marker, it is at the right position when i zoom in but at a larger zoom, it is 3 or 4 street south of the good place.

Any idea why or if it's bug in your marker implementation or in OSMDroid?

MapBox support

AnyMap supports now 3 great map libraries
Is any future ideas to add support of MapBox?

Offline map using osm

Hi,
Is it possible to use offline tiles in assets folder with AnyMaps? It works copying tiles file on SD/osmdroid folder but doesn't If I put them in assets.
According to osmdroid documentation it should be possible. Maybe the documentation refers to a newer version?
It would be very useful to switch to osm map offline when no internet connection is available.
Thanks

Adding map markers

Is there and example of how to add a map marker.

I am wanting to show my current position and a destination position.

Zoom control

Actually, many map services offer in the corner 'Zoom control'
we can click at + or -

Is it possible to implement it in AnyMap?

mMap.getUiSettings().setZoomControlsEnabled(true);

Question concerning this project.

Hi,
when I compile the example app, I can only see an open street map (on my smartphone), but no settings menu or car2gos. Is this project intended to provide a working android app to replace the official car2go app to rent car2gos, or do I get something wrong here.
I have imported this project into android studio.

screenshot_smartselect_2017-07-05-16-42-23

Various changes on my fork, which you might like to include?

Hi! Thank you very much for the AnyMaps library. I am working on implementing it into my EVMap project (https://github.com/johan12345/EVMap).
In the process have done some improvements to AnyMaps in my fork, as seen in the list below.

Is this project still maintained? Would you be open to PRs for some or all of these changes?

If yes, how should we handle this - one small PR for each of the changes? In that case it may be necessary to have the PRs built on top of each other as not all changes are completely separable from each other. Or I can make one large PR with the features you would like to have.

Major changes

  • Add a MapFragment class (ev-map@830989e, ev-map@e172821), which handles lifecycle callbacks automatically and allows the user to directly set which map implementation should be used. This alleviates the need to import a specific MapView and MapsConfiguration implementation and can automatically select the best backend based on the anymap-... libraries that are available (e.g. if you have one Build flavor for Google Maps and one for OSM, you don't need any flavor-specific code to handle the creation of the map).
  • Add an implementation for Mapbox maps in the anymaps-mapbox module (ev-map@61c95e6, ev-map@ebc4582)
  • Update dependencies (ev-map@1a3b385, ev-map@3d229c8, ev-map@5d14324) and make necessary code adjustments (Android build tools, Support Library, Google Maps, OSMDroid)

Minor changes (relevant for all AnyMaps backends)

Minor changes (OSM)

  • add attribution (ev-map@2a2c032)
  • Disable OSMDroid's zoom controller buttons (ev-map@8613bc3) for consistency with Google Maps, which does not have such buttons by default

Minor changes (Google Maps)

BitmapDescriptorFactory not initialized

Hi,
I managed to get visible the OSM map but I can't add markers because method BitmapDescriptorFactory.fromBitmap() doesn't exists in the library and BitmapDescriptorFactory.getInstance().fromBitmap() gives me the following error:
java.lang.IllegalStateException: Not initialized. Did you forgot to call MapsInitializer?
even if I call the method in onMapReady callback.

Any help or example would be appreciated. Thanks

disabling zoom gestures on AnyMap

I noticed that AnyMap's UiSettings only has 3 settings methods. Google's UiSettings has 10 settings, while Baidu's has 5. I need to disable zoom gestures on maps using setZoomGesturesEnabled(boolean), which is provided by both Baidu and Google. The AnyMaps interface does not have this method. How do I accomplish this?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.