I made it possible by creating a object that overrides "google.maps.OverlayView" and call "fromDivPixelToLatLng".
This page gave me the hint. (sorry, this page is Japanese) http://www.mwsoft.jp/programming/googlemap/google_map_v3_custom_overlay.html But the map's API seemed chaged after ↑this page is written. (you have to override "onAdd()" method.) http://code.google.com/apis/maps/documentation/javascript/reference.html#OverlayView I write down the sample code here. ## Although this code isn't cool at all and just a excerpt , I can get longitude and latitude on iPad in touchmove event. ------- //creating map "draggable=false" //how can I use both touchmove and drag?? need mode change like yahoo Japan's yubichiz? var map = new google.maps.Map(document.getElementById("map_canvas"), mapOptions); // creating marker. lat,lng is the center of the map. var marker = new HelloMarker( map, lat, lng); //using same function in mousemove and touchmove document.addEventListener("mousemove", moveFunc); document.addEventListener("touchmove", moveFunc); function moveFunc(event){ if (event != null) { var latLng = marker.getLatLng(event.x,event.y); alert(latLng.lat()); alert(latLng.lng()); } } function HelloMarker (map, lat, lng) { this.lat_ = lat; this.lng_ = lng; this.setMap(map); } /** overriding google.maps.OverlayView*/ HelloMarker.prototype = new google.maps.OverlayView(); HelloMarker.prototype.onAdd = function() { //creating the dom element to overlay on the map this.div_ = document.createElement( "div" ); this.div_.style.position = "absolute"; /* this.div_.style.fontSize = "200%"; this.div_.innerHTML = "hello!!!"; */ var panes = this.getPanes(); //adding the element panes.overlayLayer.appendChild( this.div_ ); } /** implementing required function "draw()"*/ HelloMarker.prototype.draw = function() { // 緯度、軽度の情報を、Pixel(google.maps.Point)に変換 var point = this.getProjection().fromLatLngToDivPixel( new google.maps.LatLng( this.lat_, this.lng_ ) ); // 取得したPixel情報の座標に、要素の位置を設定 this.div_.style.left = point.x + 'px'; this.div_.style.top = point.y + 'px'; } /** implementing required function "onRemove()"*/ HelloMarker.prototype.onRemove = function() { if (this.div_) { this.div_.parentNode.removeChild(this.div_); this.div_ = null; } } /* getting lat,lng from xy point*/ HelloMarker.prototype.getXY = function(lat, lng) { var point = this.getProjection().fromLatLngToDivPixel(new google.maps.LatLng(lat, lng)); return point; //this.div_.style.left = point.x + 'px'; //this.div_.style.top = point.y + 'px'; } /* getting xy point from lat,lng*/ HelloMarker.prototype.getLatLng = function(x, y) { var latlng = this.getProjection().fromDivPixelToLatLng(new google.maps.Point(x, y)); return latlng; //this.lat_ = latlng.lat(); //this.lng_ = latlng.lng(); } ------- thanks. On 10月29日, 午前12:31, Chad Killingsworth <[email protected]> wrote: > Touch events really aren't the same as mousemove. As far as I know, > there is no equivalent touch event as a mousemove. > > I believe you would have to attach to other events. Common culprits > would be drag, dragstart, dragend, click, dblclick and rightclick. > Most of the touch events (at least for the map itself) should map to > one of those events depending on the type of action. > > If you really want touch events, you might have to use addDomListener > and attach to the map div. Although, if I recall correctly, the API > prevents map events from propagating up the DOM. > > Chad Killingsworth > > On Oct 28, 1:55 am, seikoudoku2000 <[email protected]> wrote: > > > > > > > > > Hello, my name is Yosuke Tomita(@seikoudoku2000) in Japan. > > > I have a question about touchmove event on iPhone browser. > > I can get latitude and longitude in mousemove event on PC browser, but > > I can't find a way how to do it in touchmove event on iPhone browser. > > > (like this. I want to do the same thing in touchmove event !!) > > --- > > google.maps.event.addListener(map, "mousemove", moveFunc); > > function moveFunc(event){ > > alert(event.latLng.lat()); > > alert(event.latLng.lng());} > > > --- > > > Any ideas how to do that? > > > Thanks in advance. -- You received this message because you are subscribed to the Google Groups "Google Maps JavaScript API v3" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/google-maps-js-api-v3?hl=en.
