S. Koshelnyk
S. Koshelnyk

Reputation: 506

Adding marker to map by clicking on it

I am developing an app that uses maps and GPS and allows the user to make a pin/marker on map and paves the way from his current location to the place that he marked. I need to add a "standard" marker/pin to map by clicking on the place that I need to go. There is no problem to add it in code:

var position = new Position(37, -122); // Latitude, Longitude
            var pin = new Pin
            {
                Type = PinType.Place,
                Position = position,
                Label = "custom pin",
                Address = "custom detail info"
            };
            map.Pins.Add(pin);

But I need exactly to add it by click. Because the user will not go to code and he will not add a marker/pin there.

Upvotes: 2

Views: 1722

Answers (1)

hvaughan3
hvaughan3

Reputation: 11105

You could either install the TK.CustomMap plugin (or other similar plugins that have this functionality, TK.CustomMap is just the first I found but I have never tried it myself) and use it's Map Clicked Command which provides a Position where the map was clicked.

Or you could copy the code they used to make that functionality work. Below are some links to where they define that Command in the shared code and where they hook up the Command to the native map class in the iOS and Android projects (they also probably have WP code but I just can't be bothered for a platform with < 1% market share).

Shared

Android

iOS

Upvotes: 1

Related Questions