MapView, get user location (latitude, longitude), then center MapView to that

Hie guys, I am developing an app which uses the user’s location and render other markers around his location. The MapView should be centered to user’s location. I have two questions:

  1. How do I get user’s location, and center the MapView to that?
  2. How do I make the MapView zoom to accommodate the amount of markers?

Please help, I am still new to Fuse.

Hi!

u should use Observable vars in ur JS and this code:

        <Panel>
            <NativeViewHost>
                   <MapView ux:Name="myMapView" Latitude="{vMapLat}" Longitude="{vMapLng}" Zoom="{vMapZoom}"  MarkerTapped="{onMapMarkerTapped}" ShowMyLocation="true"> 
                       <Each Items="{mapMarkers}">
                           <MapMarker Latitude="{latitude}" Longitude="{longitude}" Label="{label}" />
                       </Each>
                </MapView>
            </NativeViewHost>                
        </Panel>

As far as i know: Zoom + onMapMarkerTapped are still not working propertly at least in iOS

sorry: the get location part:

    var geoLocation = require('FuseJS/GeoLocation');

    if(geoLocation.location = null) {
        var timeout = 2000;
        geoLocation.getLocation(timeout).then(function(location) {
            lat = location.latitude;
            lng = location.longitude;

            showMap(location);
        });
    }

    function showMap(loc) {
        vMapLat.value = loc.latitude;
        vMapLng.value = loc.longitude;

        //make the panel where u have the map visible 
    }

Thanks Zaulin, I will try this a soon as I get home, will keep you posted.

If many users get your app and they use it constantly, you would have to pay to google to use their api, have you think about it?

I’m developing an app to visit a city but I’m afraid of the costs of it using google’s api, so I decided to use open street maps an host the tiles in my own space (amazon aws S3), what do you think about?