admin管理员组文章数量:1387354
There are lots of gpx data out there. using google map, Kml data loading and displaying is easy. the code is:
var ctaLayer = new google.maps.KmlLayer('.kml');
ctaLayer.setMap(this.mMap);
but, I want to make a gpx data display on the google map. I know I can use babel, the converter, it's a software not library.
I have no idea what's the best way to display gpx data on google map. making converter using php(duplicated file), or making loader using javascript... --;
my current programming language is php for server.
any good idea or ment please~~~
There are lots of gpx data out there. using google map, Kml data loading and displaying is easy. the code is:
var ctaLayer = new google.maps.KmlLayer('http://gmaps-samples.googlecode./svn/trunk/ggeoxml/cta.kml');
ctaLayer.setMap(this.mMap);
but, I want to make a gpx data display on the google map. I know I can use babel, the converter, it's a software not library.
I have no idea what's the best way to display gpx data on google map. making converter using php(duplicated file), or making loader using javascript... --;
my current programming language is php for server.
any good idea or ment please~~~
Share Improve this question asked Feb 15, 2011 at 13:00 Jinbom HeoJinbom Heo 7,41014 gold badges55 silver badges60 bronze badges3 Answers
Reset to default 3You can feed GPX files to the KmlLayer constructor you have on your question. The code below worked for me:
function initialize() {
var latlng = new google.maps.LatLng(40.73, -111.93);
var myOptions = {
zoom: 10,
center: latlng,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
var ctaLayer = new google.maps.KmlLayer('http://siteyoucontrol./lake-gpx.xml');
ctaLayer.setMap(map);
}
I have two suggestions, both require some work on your side. OpenLayers is a javascript mapping API that includes a GPX reader, you could possibly use OpenLayers (with Google as a base map) or just use the GPX format reader. Alternately, you could use the OGR library mand line utility ogr2ogr
to convert from GPX to KML, possibly setting up a web service to do so. It would be easy to wrap the mand line call in a PHP script that could retrieve a GPX file by URL and convert it into KML and return the resulting KML.
I propose a very simple way to do this: perform an AJAX request to load the GPX file from Javascript, then parse it (very staightforward using jQuery) and create a polyline to display on the Google map.
More details and live example here: Display GPX tracks using Google Maps API (works with Google Maps API v3).
本文标签: phpgoogle map gpx loadinghow toStack Overflow
版权声明:本文标题:php - google map gpx loading, how to? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744525530a2610725.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论