Yandex Maps Api - How can I change location the placemark? - yandex-maps

How can I change location placemark on Yandex maps?
I added placemark and need change to location with javascript.
I've tried:
var LatLng = [ 22.2222, 33.3333 ];
myPlacemark.setPosition(LatLng);
but it is not working.

According to the API documentation the method name is setCoordinates and it's applied to the geometry of the placemark, so the following should work:
myPlacemark.geometry.setCoordinates(LatLng)

Related

Data needed for google maps api

When using Google API what will be the data that is needed for an application that shows locations of different places,is latitude and longitude will be necessary , the locations that needed to shown is already in Google maps. Or just the address or the name of the place will be enough.
Can anybody help me ?
When placing markers on a map at a minimum you need the lat and long vertices.
You can use a various Google APIS for getting data like a Google Places library to search by a place name or address: https://developers.google.com/maps/documentation/javascript/examples/places-searchbox
You can also use a reverse geocode service to search by a lat long: https://developers.google.com/maps/documentation/javascript/examples/geocoding-reverse
Or if you have your own data you can create the markers like shown in this example:
var myLatlng = new google.maps.LatLng(36.166461, -86.771289);
app.marker = new google.maps.Marker({
position: (myLatlng),
data:this,
map: app.map,
title: 'Hello marker!!'
});
https://jsfiddle.net/loanburger/48asvsed/

How to get a Google Place ID from a Google GMS Address

I have seen previous posts regarding the conversion from a Google Place ID to an address; however I am interested in the opposite.
I have the GMS Address of the desired location but I want to acquire the Google Place ID in order to present more details to the user. From what I have seen on Google's iOS API website, you can attain a Google Place ID from an Autocomplete feature (for user searching), a selected location feature, or a current location feature.
My application intends to display multiple locations in which I already have the addresses for. The user can select individual locations for more details in addition to receiving details upon arrival. Therefore the features listed above are not ideal.
I have also tried using Google's Web API with features such as "Text Search Requests" & "Nearby Search Requests" however I am receiving "Zero Results".
Are there other methods that I haven't thought of and/or seen?
How about the Place ID finder in the Google Maps JavaScript API.
A place ID is a textual identifier that uniquely identifies a place. It is also available for most locations, including businesses, landmarks, parks, and intersections. These IDs are stable, meaning that once you've identified the place ID for a place, you can reuse that value when you next look up that place.
You can use the same place ID across the Google Places API and a number of Google Maps APIs. For example, you can use the same place ID to reference a place in the Places API, the Google Maps JavaScript API, the Google Maps Geocoding API, the Google Maps Embed API and the Google Maps Roads API.
Here is the sample code use for this.
function initMap() {
var map = new google.maps.Map(document.getElementById('map'), {
center: {lat: -33.8688, lng: 151.2195},
zoom: 13
});
var input = document.getElementById('pac-input');
var autocomplete = new google.maps.places.Autocomplete(input);
autocomplete.bindTo('bounds', map);
map.controls[google.maps.ControlPosition.TOP_LEFT].push(input);
var infowindow = new google.maps.InfoWindow();
var marker = new google.maps.Marker({
map: map
});
marker.addListener('click', function() {
infowindow.open(map, marker);
});
autocomplete.addListener('place_changed', function() {
infowindow.close();
var place = autocomplete.getPlace();
if (!place.geometry) {
return;
}
if (place.geometry.viewport) {
map.fitBounds(place.geometry.viewport);
} else {
map.setCenter(place.geometry.location);
map.setZoom(17);
}
// Set the position of the marker using the place ID and location.
marker.setPlace({
placeId: place.place_id,
location: place.geometry.location
});
marker.setVisible(true);
infowindow.setContent('<div><strong>' + place.name + '</strong><br>' +
'Place ID: ' + place.place_id + '<br>' +
place.formatted_address);
infowindow.open(map, marker);
});
}
Just take note that this example requires the Places library. Include
the libraries=places parameter when you first load the API. For
example:
script src="https://maps.googleapis.com/maps/api/jskey=YOUR_API_KEY&libraries=places"

Google Directions API, Get Coord then show how to get to Y

I'm trying to make a website thats simply shows your location and how you get to the location where you want to go.
To get my current location im using this code i found here on stack:
// Get the coordinates
navigator.geolocation.getCurrentPosition(show_map);
function show_map(position) {
var latitude = position.coords.latitude;
var longitude = position.coords.longitude;
// post to your controller
var url = "/Home/Index?latitude=" + latitude + "&longtitude=" + longitude;
$.post(url, function(data) {
});
}
I've breakpointed it and it does give me the coordinates for position.
But my problem is, how do I show how to get to point B(Point B will be hardcoded coordinates)?
I've looked into Google Directions API aswell as Distance Matrix API, and for a newbie like me the I find the documentation quite hard to understand. I'm trying to do this in an MVC 6 project, am I approaching this the wrong way? Should i keep looking at Google Directions API?
This can all be performed client side via the Google Maps API and their Direction Service. Have you seen this -> https://developers.google.com/maps/documentation/javascript/examples/directions-simple

How to search a particular place in google maps sdk in ios

Suppose I am writing a New york in UITextfield and search it via google map sdk in ios.Can i get latitude and longitude of new york via sdk.I want a google map api link like this.
http://maps.googleapis.com/maps/api/geocode/json?address=1600+Amphitheatre+Parkway,+Mountain+View,+CA&sensor=true_or_false
sorry for bad english writing skills.
API which u used to fetch Geocode will work but you have to pass the correct sensor,
http://maps.googleapis.com/maps/api/geocode/json?address=1600+Amphitheatre+Parkway,+Mountain+View,+CA&sensor=true
and got the result,
...
"location" : {
"lat" : 37.4219985,
"lng" : -122.0839544
}
...
Sensor - Attribute used to find whether your current location can be tracked or not.
Hope this answers your question.
Thanks,
Prasanna

html5 geolocation for user location in mvc3

i want to get the user location information like city, area etc using html5 geolocation,i tried the below article but with that im getting latitude and longitude, i want to get the city and area information,
http://www.dotnetcurry.com/ShowArticle.aspx?ID=782
When you have the location of the user, you'll need to do a reverse geocoding to get information about the location such as city, etc.
Have a look at the reverse geocoding API for Google Maps.
navigator.geolocation.getCurrentPosition(function(pos){
var latlng = new google.maps.LatLng(pos.coords.latitude, pos.coords.longitude);
geocoder.geocode({'latLng': latlng}, function(results, status) {
console.log(results);
// Analyze results and find the info you need.
});
});
Check out How to reverse geocode without Google for information about geocoding without using Google Maps.

Resources