Jump in a map

23 views
Skip to first unread message

Marko

unread,
Jun 24, 2009, 12:31:18 PM6/24/09
to SIMILE Widgets
Hello,

Recently i've seen an exhibit map with links underneath where you
could jump to a point in the map. Unfortunately, I have forgotten to
bookmark the page. Does anyone how to include the jumps?

--
Regards,
Marko

David Karger

unread,
Jun 24, 2009, 12:33:46 PM6/24/09
to simile-...@googlegroups.com
the presidents map uses a "coordinator" such that when you click on a
president in a timeline the map jumps to their place in the map.

Marko

unread,
Jun 24, 2009, 12:50:05 PM6/24/09
to SIMILE Widgets
Thanks, but that is not what I was looking for. There were links to
places on the map, right below the map. The links where just plain
html, very simple: <a href="javascript:???">link</a>

John Callahan

unread,
Jun 24, 2009, 1:59:44 PM6/24/09
to simile-...@googlegroups.com
I'm not sure if this is the proper way to do this, but the following works for me.

Basically, I define a simple "map" variable outside of all Exhibit javascript, so it's accessible to all of your own code.  Then, override the Exhibit function that produces the Google Map and assign it to the "map" variable.  So, in your Exhibit, add the following AFTER referencing the exhibit and map extensions js files. 

<script type="text/javascript">
var map;
var oldMapViewReconstruct = Exhibit.MapView.prototype._reconstruct;

Exhibit.MapView.prototype._reconstruct = function() {
  oldMapViewReconstruct.call(this);
  map = this._map;
};
</script>


You can then do things like:

<a href="javascript:maptest();">Test GMap</a>

function maptest() {
  //to add a marker
  var cpoint = new GLatLng(39.823,-75.723);
  var cmarker = new GMarker(cpoint,{draggable: true});
  map.addOverlay(cmarker);

  //to pan/move to a location
  map.panTo(new GLatLng(37.4569, -75.1569));
}


- John

John Callahan

unread,
Jun 24, 2009, 2:12:46 PM6/24/09
to simile-...@googlegroups.com
Also take a look at this.  I totally forgot about it.  You could use the mapConstructor parameter to build your own map and functions.  This works great if you're just panning around or adding listeners. If your adding points to the map, note that the points will be removed each each time to the data is filtered, such as making a facet selection.

http://groups.google.com/group/simile-widgets/browse_thread/thread/e75b94bd6145479e/33d53881cb8c1029?lnk=gst&q=mapConstructor#33d53881cb8c1029

- John

David Huynh

unread,
Jun 29, 2009, 10:15:09 AM6/29/09
to simile-...@googlegroups.com
Marko,

First, you need to assign an id to the map view

<div ex:role="view" ex:viewClass="Map" id="the-map-view" ...

Then to drive the map, do something like

exhibit.getComponent("the-map-view")._map.setCenter(new GLatLng(lat,
lng), zoom);

David

John Callahan

unread,
Jun 29, 2009, 9:45:52 PM6/29/09
to simile-...@googlegroups.com
Excellent.  That is a much better solution.  I was looking for something exactly like that but didn't know about the getComponent function.  (I really need to get that documentation going...it's just been an extraordinarily chaotic past couple of weeks at home and work.)   Thanks.

- John

Marko

unread,
Jun 30, 2009, 6:29:33 PM6/30/09
to SIMILE Widgets
Thanks!

Still, I remember seeing it in another way. Still haven't found the
example back, but I will post it here after I found it again.
Reply all
Reply to author
Forward
0 new messages