javascript - Create a unique URL for linking to data pulled from a database -


is possible create unique url link information called , displayed database?

[i struggling articulate question, suggestions revising welcome.]

specifics: have page includes embedded map , related information each location stored in separate database. users can navigate through locations clicking markers on map or using navigation buttons in sidebar. either case zooms in on marker , displays information location in sidebar. works fine, because information placed in divs, page's url same regardless of being displayed.

i able create , share links individual locations, open point selected in map , information displayed in sidebar.

i use javascript function call information database. here simplified version of code:

<a href="#" onclick='callmarker(markernum);'>click me</a>   function callmarker(markernum) {         var sql = new data.sql({ user: 'me' });         var sql_query = "select * map_name marker_id = " + markernum;         sql.execute(sql_query)         .done(function(data) {             console.log(data.rows[0]);              var title = data.rows[0].title;              // displays id of object in external information box             document.getelementbyid("title").innerhtml= data.rows[0].title; } 

since each location tagged unique id number (marker_id) in database, seems appended end of current url create unique url associated each point. or maybe id number (marker_id) somehow assigned div id variable within page. not sure how either or if either work.

any ideas or direction appreciated. have been searching lot of different approaches, have not found seems address problem.

if don't want on server provide unique url, can use client side hash urls in form /mymap#uniqueid. hashed part of url accessible in javascript so:

window.location.hash 

you can set property on location users click around on map. in callmarker function can like:

if(history.pushstate)      history.pushstate(null, null, '#myhash');       else       location.hash = '#myhash';  

in newer browsers first method avoids hard refresh.

you can grab value on page load event render appropriate point on map , sidebar information.


Comments

Popular posts from this blog

c# - Validate object ID from GET to POST -

node.js - Custom Model Validator SailsJS -

php - Find a regex to take part of Email -