i found this code :

var overlay = new google.maps.OverlayView();
 overlay.draw = function() {};
 overlay.onAdd = function() {
var projection = this.getProjection();
var pixel = projection.fromLatLngToContainerPixel(marker.getPosition());
console.log(pixel);
 };
 overlay.setMap(map);

but the problem if am in the middle of loop ,it kip report the firs marker !


On Friday, 18 March 2016 03:13:35 UTC+2, Bashar Al Masri wrote:
>
> Dear all 
> i want to know what is the exact marker XY base on my PC screen  not base 
> on the world map 
>
> This code return the marker xy base on world map 
>
> var marker = new google.maps.Marker({
> position: {lat:  '111111' , lng: '-333333' },
> map: map,
> title: 'Hello World!'
> });
> marker.setMap(map);
> var scale = Math.pow(2, map.getZoom());
> var nw = new google.maps.LatLng(
> map.getBounds().getNorthEast().lat(),
> map.getBounds().getSouthWest().lng()
> );
> var worldCoordinateNW = map.getProjection().fromLatLngToPoint(nw);
> var worldCoordinate = 
> map.getProjection().fromLatLngToPoint(marker.getPosition());
> var pixelOffset = new google.maps.Point(
> Math.floor((worldCoordinate.x - worldCoordinateNW.x) * scale),
> Math.floor((worldCoordinate.y - worldCoordinateNW.y) * scale)
> );
> console.log(pixelOffset),
>
> How can i get the actual marker coordinate and pass it to other element on 
> my html .
>
> Regards
>
>   
>

-- 
You received this message because you are subscribed to the Google Groups 
"Google Maps JavaScript API v3" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to google-maps-js-api-v3+unsubscr...@googlegroups.com.
To post to this group, send email to google-maps-js-api-v3@googlegroups.com.
Visit this group at https://groups.google.com/group/google-maps-js-api-v3.
For more options, visit https://groups.google.com/d/optout.

Reply via email to