ubilabs / google.maps.polyline.edit Goto Github PK
View Code? Open in Web Editor NEWEnables Google Maps API V3 Polyline Editing
Home Page: http://ubilabs.github.com/google.maps.polyline.edit
Enables Google Maps API V3 Polyline Editing
Home Page: http://ubilabs.github.com/google.maps.polyline.edit
I'm getting a "Uncaught TypeError: Cannot read property '_e3' of undefined" when I put the code for the edit ended event.
var map;
var snappedPolyline;
function initMap() {
$.getScript("polyline.edit.js", function(){});
$.getScript("epoly.js", function(){});
$("#startEdit").click(function(){
snappedPolyline.edit()
});
$("#endEdit").click(function(){
snappedPolyline.edit(false)
});
google.maps.event.addListener(snappedPolyline, 'edit_end', function(){
alert("Edit ended");
});
//Mapa principal
var centro = {lat: -31.5403194, lng: -68.5269984};
map = new google.maps.Map(document.getElementById('map'), {
center: centro,
zoom: 15,
mapTypeId: google.maps.MapTypeId.ROADMAP
});
var L8_IDA = "-31.492649,-68.533279;-31.493490,-68.533257;-31.493481,-68.532249;-31.482330,-68.532158;-31.484890,-68.539818;-31.481400,-68.541489;-31.481970,-68.543167;-31.483000,-68.542648;-31.482500,-68.541008;-31.484930,-68.539909;-31.488169,-68.549065;-31.495560,-68.544601;-31.498369,-68.543251;-31.502110,-68.541229;-31.501699,-68.535179;-31.502586,-68.535118;-31.502621,-68.535332;-31.503500,-68.535202;-31.504251,-68.535179;-31.504343,-68.535042;-31.506149,-68.534897;-31.510429,-68.534073;-31.510941,-68.537071;-31.511074,-68.538231;-31.511551,-68.538185;-31.521030,-68.536942;-31.520639,-68.536209;-31.520624,-68.535828;-31.520496,-68.535507;-31.519709,-68.534088;-31.518995,-68.533081;-31.520321,-68.532501;-31.521589,-68.531853;-31.522449,-68.531570;-31.522760,-68.533897;-31.523010,-68.536758;-31.523041,-68.538177;-31.525141,-68.538002;-31.526331,-68.537842;-31.526459,-68.538849;-31.527620,-68.538734;-31.527721,-68.539520;-31.528721,-68.539398;-31.534731,-68.538742;-31.534981,-68.538757;-31.535110,-68.538857;-31.535191,-68.538849;-31.535250,-68.538811;-31.535320,-68.538643;-31.535139,-68.538277;-31.535061,-68.537788;-31.534929,-68.535370;-31.534269,-68.527679;-31.533649,-68.519302;-31.537319,-68.518959;-31.539930,-68.518791;-31.539700,-68.514908;-31.541790,-68.514633;-31.543171,-68.515579";
var route = L8_IDA.replace(/;/g , "|");
runSnapToRoad(route);
}
// Snap a user-created polyline to roads and draw the snapped path
function runSnapToRoad(ruta) {
$.get('https://roads.googleapis.com/v1/snapToRoads', {
interpolate: true,
key: "AIzaSyDwgwqcIIBki__bcQJWJ6uMn-m3HwLjiVU",
path: ruta
}, function(data) {
processSnapToRoadResponse(data);
drawSnappedPolyline();
});
}
// Store snapped polyline returned by the snap-to-road method.
function processSnapToRoadResponse(data) {
var queryRecorrido = "";
snappedCoordinates = [];
placeIdArray = [];
for (var i = 0; i < data.snappedPoints.length; i++) {
var latlng = new google.maps.LatLng(
data.snappedPoints[i].location.latitude,
data.snappedPoints[i].location.longitude);
queryRecorrido += "INSERT INTO `recorrido` (`idLinea`, `lat`, `lng`, `orden`) VALUES (1, " + data.snappedPoints[i].location.latitude + ", " + data.snappedPoints[i].location.longitude + ", " + i + ");"
snappedCoordinates.push(latlng);
placeIdArray.push(data.snappedPoints[i].placeId);
}
var stop = 1;
}
// Draws the snapped polyline (after processing snap-to-road response).
function drawSnappedPolyline() {
snappedPolyline = new google.maps.Polyline({
path: snappedCoordinates,
strokeColor: 'green',
strokeWeight: 3
});
snappedPolyline.setMap(map);
//snappedPolyline.edit();
}
When onmouseover a vertex an HTTP request, onmouseout an HTTP request, when moving a vertex a flow of HTTP requests.
I tested on Firefox an it doesn't happen, so I guess it does a better job with the cache.
I though I should report it.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.