How to replace data in my javascript file with hyperlink to this file -
i'm having script view polygons on google maps, want change polygon coordinates when click on hyperlink. script i'm using:
<!doctype html> <html> <head> <script src="https://maps.googleapis.com/maps/api/js?key=my_api_key_is_here&libraries=geometry,places&ext=.js" ></script> <script src="http://code.jquery.com/jquery-latest.min.js" type="text/javascript"></script> <div id="map_canvas" ></div> <style> /* set map height explicitly define size of div * element contains map. */ #map_canvas { height: 100%; } /* optional: makes sample page fill window. */ html, body { height: 100%; margin: 0; padding: 0; } </style> </head> <body> <script> var map; var bounds = new google.maps.latlngbounds(); // polygon var polygonstr = "polygon (24.935955 42.32732, 24.943297 42.3268, 24.944593 42.322991, 24.94438 42.317172, 24.940584 42.317919, 24.936224 42.320232, 24.933244 42.322896, 24.927394 42.327057, 24.934312 42.328296, 24.93242 42.326795)"; function initialize() { map = new google.maps.map( document.getelementbyid("map_canvas"), { center: new google.maps.latlng(42.156801, 24.749468), zoom: 4, maptypeid: google.maps.maptypeid.roadmap }); drawpoly(polygonstr); map.fitbounds(bounds); } function drawpoly(multipolygonwkt) { var polylines = []; var toreturn = []; multipolygonwkt = multipolygonwkt.replace("polygon ", ""); var formattedvalues = multipolygonwkt.replace("))", ""); formattedvalues = formattedvalues.replace("((", ""); var linescoords = formattedvalues.split("), ("); (i = 0; < linescoords.length; i++) { polylines[i] = []; var singleline = linescoords[i].split(", "); (j = 0; j < singleline.length; j++) { var coordinates = singleline[j].split(" "); var latlng = new google.maps.latlng(parsefloat(coordinates[1]), parsefloat(coordinates[0])); bounds.extend(latlng); polylines[i].push(latlng); } } toreturn.push( new google.maps.polygon({ map: map, paths: polylines, strokecolor: 'red', strokeopacity: 1, strokeweight: 2, zindex: 1 })); return toreturn; } google.maps.event.adddomlistener(window, "load", initialize); </script> </body> </html>
when try call file hyperlink new coordinates nothing hapens example 'file:///c:\users\desktop\myfilename.html?q="polygon (here put new coordinates)" idea change coordinates in script new 1 hyperlink. possible? if possible how? forgot file on computer , want open is.
edit: here more info want do.i have created attribute in program use - geomedia , can create hyperlink coordinates of drawn polygon. enter image description here want when click link have polygon opened in google maps. tryed make hyperlink directly google , couldn't find how configure url. mean single place there "?q=" , didn't find how tell google polygon , go ahead , start searching alternative way. found script fine if ad coordinates manually it's working , need make work given hyperlink. think there should way , javascript skills low please patient when trying tell me how :).
new edit: i'm totaly stuck , realy need , bacause tryed lot of different examples , functions , still no progres. i'm doing wrong , can't work. must give since here can't helpfull soliution.at least if can give me link example can see how made , how modify file nice.
in order acess coordinates in hyperlink, must extract them, exampl can use php, polygone this:
var polygonstr = <?php print($_get['q']) ?>;
Comments
Post a Comment