angularjs-google-maps icon indicating copy to clipboard operation
angularjs-google-maps copied to clipboard

Have no idea how to provide center coordinates dynamically

Open dmitriykharchenko opened this issue 11 years ago • 10 comments

<ng-map center="[{{ a }}, {{ b }}]"><ng-map>

— Just not works.

Do I have to provide them always as string without ng expression?

dmitriykharchenko avatar Nov 16 '15 12:11 dmitriykharchenko

try this <ng-map center="{{ a }}, {{ b }}"><ng-map>

allenhwkim avatar Nov 16 '15 15:11 allenhwkim

Not works also. I read sources and it is because there is no evaluation of expressions from center attr in map controller

dmitriykharchenko avatar Nov 16 '15 15:11 dmitriykharchenko

Please provide me a plunker example. This example works fine, http://ngmap.github.io/#/map_with_dynamic_center.html

allenhwkim avatar Nov 16 '15 18:11 allenhwkim

I have no idea, it works in your plunker. And today get working in my project, but from time to time. I'll provide plunker after I understand the reason why it happening. Only have screenshot from project page: screenshot 2015-11-17 10 48 09

dmitriykharchenko avatar Nov 17 '15 04:11 dmitriykharchenko

I am having the same problem :( any ideas on how to fix this?

larissaleite avatar Nov 02 '16 01:11 larissaleite

@larissaleite you can fix this ?

cristianounix avatar Jan 30 '17 03:01 cristianounix

	if (navigator.geolocation) {
	navigator.geolocation.getCurrentPosition(function(position){
  	$scope.$apply(function(){
    	$scope.position = position;
  	});
	});
}

Steven-Chang avatar Feb 12 '17 09:02 Steven-Chang

Ran into a similar problem. For me it was that I was using center= on my marker tag instead of ng-map.
This code is working, and provides a drag-able marker w/ function to run on that event: <ng-map center="[{{latitude}}, {{longitude}}]"> <marker position="{{latitude}},{{longitude}}" draggable="true" on-dragend="getCurrentLocation()"></marker> </ng-map>

tedpennington avatar Sep 19 '17 15:09 tedpennington

how can I get the coords when moving the marker?

isaacSolano avatar Apr 12 '18 21:04 isaacSolano

@isaacSolano

<marker position="[40.74, -74.18]" centered="true" draggable="true" on-dragend="vm.getMarkerLocation()"></marker>
    vm.getMarkerLocation = function(){
        var lat = this.position.lat()
        var lng = this.position.lng()
        console.log(lat,lng)
    }

phuwin1995 avatar Jun 04 '18 12:06 phuwin1995