I need a section of my application to have an interactive map of a square area that consists of about 10 buildings. You have to be able to click on a building and receive some information about it. I know there are a couple of ways to go about this, but I'm hoping someone with some background in this can give me some tips.
Here are some ways that I can think about accomplishing this.
I already implemented Google Maps API and it works quite well, but doesn't really have the effect I was looking for. Google Maps requires an internet connection and gives you access to the entire map. I need it to be locked into one area.
This seems like a great alternative. I'm sure I can come up with a simple image map that will give you more information when you click a certain building. The only problem with this is that you also need an internet connection.
I've never really looked into this too much, but I heard it is difficult and a pain to implement. It would be able to run locally, but is it worth it?
Are there any other way to go about developing an interactive map? Something to keep in mind is that I would also like to someday port this over to iOS (if anyone has any experience with that as well)
Mapbox is an interactive map tool that's used by some huge names like the New York Times, BMW, and Instacart. With Mapbox, you can create your own custom map, or use templates to build a gorgeous interactive map. Some of the best Mapbox-powered maps offer a fantastic user experience.
Create a new map by signing into your Google account, clicking the Map icon. 3. Then click the hamburger menu (in the top left hand corner) and then click “Your Places” (about half way down) Page 2 2 4. Click the “Maps Tab” then click, “Create Map” down the bottom.
If you want full control and are comfortable using html and javascript, I would highly recommend using the open source OpenLayers library. You can create an html page, save it in assets and run it locally on the device. You can create your own set of map tiles or even use one single jpeg file and then 'map' the buildings you want on it and then use the simple but extensive OpenLayers API to allow for building selection and information display. It even has multi-touch functionality built in for panning and zooming. Works great on and off mobile.
You can see a list of examples here. Doing a simple view source on any of the examples will give you a very clear idea of what they are doing. You can also take a look at this example which plots a bunch of image thumbnails on the map area from flicker with the ability to click for more details. This example uses an online feed, but you can easily use a local one.. even one passed in from the app to the webview.
ps. I have no affiliation to OpenLayers other than actively using it for my projects.
It might take 10 pages to answer your question from the start.
Let's look here first: https://developers.google.com/maps/documentation/android/hello-mapview
After you are able to use MapView, you just need to create your ItemizedOverlay Class.
Replace this class with HelloItemizedOverlay in the Tutorial.
public class GooglerMapItemizedOverlay extends ItemizedOverlay {
private ArrayList<OverlayItem> mOverlayItems = new ArrayList<OverlayItem>();
private Context mContext;
private Paint rectPaint, textPaint;
public GooglerMapItemizedOverlay(Drawable defaultMarker, Context context) {
super(boundCenterBottom(defaultMarker));
mContext = context;
populate();
}
@Override
protected OverlayItem createItem(int i) {
return mOverlayItems.get(i);
}
public void addOverlayItem(OverlayItem overlay) {
mOverlayItems.add(overlay);
populate();
}
@Override
public int size() {
return mOverlayItems.size();
}
public void clear(){
mOverlayItems.clear();
populate();
}
@Override
protected boolean onTap(int index) {
// information goes here
OverlayItem item = mOverlayItems.get(index);
AlertDialog.Builder dialog = new AlertDialog.Builder(mContext);
dialog.setTitle(item.getTitle());
dialog.setMessage(item.getSnippet());
dialog.show();
return true;
}
}
Hope this helps.
Google Maps
Here is how to do it (I did it and it works):
ItimizedOverlays
that you created to handle actionsThere are good answers on StackOverflow for each one of these steps.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With