I added a WKInterfaceMap object to our Apple Watch app. When I press it to get directions, it always says "Unknown location" but gives the right directions. How can I get it to populate with the name of the location?
Yep Like RPM is saying, for now if apple "maps" does not know the location's name, it tells "Unknown location"...
if your location is to an know location, like yelps locations, it will display the location name...
i hope that Apple will implement a way to set the title of the location...
I know this is an old question, but I ran across it recently and we just now came up with a solution. We added a tap gesture recognizer to the WKInterfaceMap in the interface builder, dragged its selector to a function in the interface controller. In that function add:
let center = CLLocationCoordinate2DMake(latitude, longitude)
let placemark = MKPlacemark(coordinate: center, addressDictionary: nil)
let mapItem = MKMapItem(placemark: placemark)
mapItem.name = "Name of location"
mapItem.openInMaps(launchOptions: nil)
Related
I'm developing an app in xamarin forms supposed to works on android and ios.
The problem is that IOS maps displays a wrong location.
IOS Location (WRONG)
Android Location (RIGHT)
Code:
switch (Device.RuntimePlatform)
{
case Device.iOS:
uri = new Uri(string.Format("http://maps.apple.com/?ll={0}", x + ',' + y));
System.Diagnostics.Debug.WriteLine(uri);
Device.OpenUri(uri);
break;
case Device.Android:
uri = new Uri("https://www.google.com/maps/search/?api=1&query=" + x + ',' + y);
System.Diagnostics.Debug.WriteLine(uri);
Device.OpenUri(uri);
break;
}
In this example x="39.7301803" and y="-8.8438668"
UPDATE
Replacing the code above with ExternalMaps plugin
var success = CrossExternalMaps.Current.NavigateTo(Store.Name, Double.Parse(x), Double.Parse(y));
Exactly the same result :(
Both of your links (manually put together) open in the right app and point to the same location
Google-maps
Apple-maps
But when I set the y param to "0" I end up in the exact area of your wrong screenshot. Could it be that there is a problem in your code? Like y not being set (prior to the snippet)
Could you share more of your code?
The difference between both platforms is how you build the string. I would suggest to change the iOS part to:
uri = new Uri("http://maps.apple.com/?ll="+ x + ',' + y));
I can not comment that is why I am answering your question. I do not know why you are executing url to Device browser. I suggest better you use the "Map" control from Xamarin.Forms name space. I think it will full fill your requirement for set position on the exact point on the map.
Here is the good sample of Xamarin.Forms.Map
UPDATE-1
I am not sure weather you want to use plugin or not. I found one good plug which can open external maps to a specific geolocation or address in your Xamarin.iOS, Xamarin.Android, Windows, and Xamarin.Forms projects.
For more details and information please check this.
Just found and tested code here as well not sure if it is helpful to you. You might got the same earlier as well.
I can find no explanation on what these are actually supposed to do.
There are examples on:
https://jxbrowser.support.teamdev.com/support/solutions/articles/9000102480-forwarding-mouse-events
but 629 and 373 ? I can't figure out what those values are for. I can get the same behaviour with any value for those.
What if you one also sets windowX and windowY ?
What would they do to the result click?
I am looking to be able to click and move on a google map. Is that possible?
The x and y values define the mouse event coordinate inside the browser content area.
The globalX and globalY values define the screen coordinate of the mouse event.
The windowX and windowY are deprecated. If you set them, this doesn't affect anything.
For more detailed information about working with Google Maps, please take a look at the article.
Your browserView must be active/focused first!
Then, let's do this way:
public static void simulateMouseClickOnElement(Browser browser, BrowserView browserView, DOMElement element){
Rectangle rect = element.getBoundingClientRect();
Point ptOnScreen = new Point(rect.x , rect.y );
SwingUtilities.convertPointToScreen(ptOnScreen, browserView);
forwardMouseClickEvent(browser,MouseButtonType.PRIMARY,rect.x,rect.y, ptOnScreen.x, ptOnScreen.y);
}
JxBrowser is the BEST automation or crawling/hacking tool! Selenium is a best alternative choice due to the TCO.
In one of my watchKit application I need to show the route between two locations on the WKInterfaceMap. I searched for different links including Apple Developer Link. But I didn't find any way to display the route on the WKInterfaceMap.
Then, how the Uber watchKit App displays the route on the WKInterfaceMap? Is it the Map or an WKInterfaceImage/UIImage?
Below is the screenshot for the Uber App.
My guess is that they are be finding the route on the iOS app then passing it on to the watch in the form of a WKInerfaceImage
WKInterfacemap is non interactive map. If you just want to give the user driving directions, use below code where you can specify destination lat and long and open Map application on iWatch. It will launch Map application on iPhone, from there WatchOS will receive routing information.
let coordinate = CLLocationCoordinate2DMake( <ENTER DESTINATON LATITUDE>, <ENTER DESTINATON LONGITUDE>)
let mapItem = MKMapItem(placemark: MKPlacemark(coordinate: coordinate, add ressDictionary:nil))
mapItem.name = <DESTINATION NAME>
mapItem.openInMaps(launchOptions: [MKLaunchOptionsDirectionsModeKey : MKLaunchOptionsDirectionsModeDriving])
I have to write a script for Google Maps V3 which will do the following:
Place a marker on a map based on a set of coordinates and possbibly change the address after the page has been loaded
Allow the user the drag the mark to replace it elsewhere
Collect the new coordinates once the marker has been moved.
The first part is basic enough and should be fine, changing the address after the page is loaded should only be a matter of calling back the same function?
I am not sure where to start on the draggable marker and collecting hew coordinates.
Would anyone know of scripts / API's or where in the doc should I start?
Have you checked the Google Maps Javascript API V3 Reference to see whether the google.maps.Marker class has :
a draggable option
an dragend event
a getPosition method
Hint: The answer might just be "yes" to all three, and you don't need much else to solve your problem.
I have an application where the user will click a button and map an address on the native google map API. I can find lots of examples of how to do this with lat + long, but nothing about how to pass an address. I can do the following, where homeLoc.text is a latitude and longitude: navigateToURL(new URLRequest("http://maps.google.com/?q=" + homeLoc.text));
It is hard to believe this would be difficult, but I can not find any examples using a street address.
Anybody out there done something like this? Must be a pretty common use case.
Thanks,
Mark
Right. The problem with using an address directly is that it doesn't know how many possible outcomes there can be. It could be 1, or it can be millions.
Because of this, google insists that you use their Geocoding API to get a LatLong from an Address. If only one result is returned, you can handle opening google maps at the correct location, but if more than one (or none) is returned, you can handle it yourself in the app before continuing.
Alert.show("Open new tab to search in Google Maps?", "No places found", Alert.YES |
Alert.NO, null, alertListener, null, Alert.NO);
function alertListener(eventObj:CloseEvent):void {
// Open Google in new tab.
if (eventObj.detail==Alert.YES)
{
var url:String = "http://maps.google.com.au/maps?q=" + onelineaddress.text;
var urlReq:URLRequest = new URLRequest(url);
navigateToURL(urlReq, "_blank");
}
}
This works for me.