Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>i had exactly the same initial situation as you described.</p> <p>when you see the map tiles there are obviously some missing to see a position on the map:</p> <p><strong>1. you need a location</strong>. i recognized that setting only a geo position via DDMS view to the emulator is not enough. you have to explicitly press every time the "Send" button in DDMS to trigger a location update on your emulator. (just to mention: on a real the device you have sometimes to walk a bit to make your device get a location update ;), i was so pissed off until i walked around thinking of what to do now ^^)</p> <p><strong>2. you need a correct implementation of ItemizedOverlay with an correct OverlayItem</strong>. i wrote my own overlay which got bit "complicated". if you're not sure if your implementation is correct, use this guide to create an implementation with minimal changes <a href="http://developer.android.com/resources/tutorials/views/hello-mapview.html" rel="noreferrer">Map view tutorial android developers</a></p> <p>or use this:</p> <pre><code>private class MyItemizedOverlay extends ItemizedOverlay { private ArrayList&lt;OverlayItem&gt; mOverlays = new ArrayList&lt;OverlayItem&gt;(); public MyItemizedOverlay(Drawable defaultMarker) { super(boundCenterBottom(defaultMarker)); } public void addOverlay(OverlayItem overlay) { mOverlays.add(overlay); populate(); } @Override protected OverlayItem createItem(int i) { return mOverlays.get(i); } @Override public int size() { return mOverlays.size(); } } private void updateLocationOverlay() { if (location == null) { return }; List&lt;Overlay&gt; mapOverlays = mapView.getOverlays(); Drawable drawable = this.getResources().getDrawable(R.drawable.XXXX); MyItemizedOverlay myItemizedOverlay = new MyItemizedOverlay(drawable); GeoPoint point = new GeoPoint((int)(location.getLatitude() * 1E6), (int)(location.getLongitude() * 1E6)); OverlayItem overlayitem = new OverlayItem(point, "Hola, Mundo!", "I'm in Mexico City!"); myItemizedOverlay.addOverlay(overlayitem); mapOverlays.add(myItemizedOverlay); } </code></pre> <p>i want specially point out that you must call boundCenter or boundCenterBottom on the drawable. else it will not be drawn. be also careful if you use different markers in the same overlay with overlayItem.setMarker, that u call it there too.</p> <p><strong>3. you have to move the view on the map to your point</strong>. you can achieve this like this:</p> <pre><code>MapController mapController = mapView.getController(); mapController.setCenter(point) </code></pre> <p>i recognized that the function <em>mapController.zoomToSpan</em> does not work. (at least for me, i am still developing on this app). maybe its the same with <em>animateTo</em>. i did not try. set center works. (and setZoom level also).</p> <p>Maybe there is something in the points i mentioned which could lead to, that your map does not work like you want.</p> <p>Good luck!</p> <p>edit: i forgot to mention that i am still getting that factory client error even it works to get a valid location, real on device and fake on emulator via ddms send). i just ignore for now.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload