1

I need to redirect via href to another page and then execute my onClick function. I want that when you click on "Zobrazit na mapě" in here http://mapaskladek.aspone.cz/List you will be redirected to index page and map will be centered on the marker of the record you have clicked.

Also console now returns error: Uncaught TypeError: Cannot read property centerMarker of undefined and I dont understand why

You can find all source codes uploaded in http://mapaskladek.aspone.cz/

Jakub
  • 285
  • 4
  • 21
  • 2
    if this is about google-map, then you are missing a critical tag in your question – renakre May 01 '15 at 17:14
  • 1
    IMO, your request is way too broad. You'll need to be more specific and identify a problem you are having. Just telling us that your browser console is throwing an exception really is very vague. Where is the exception coming from? What steps have you already attempted? – Justin Russo May 01 '15 at 17:15
  • @erkaner it is not primarily about google-map, I know how to center map, but I dont know how to redirect to index page and then use my function to center. @JustinRusso I have Anchor tag like this `Zobrazit na mapě` I think I have this error bcs my web at first applies that onclick function and then redirects, so it is TypeError – Jakub May 01 '15 at 17:20

1 Answers1

1

You should GET or POST the information about where the map should be centered to the URL. So for example, if before you were redirecting to http://mapaskladek.aspone.cz/, now you should redirect to something like http://mapaskladek.aspone.cz?center=true&lat=[latitude]&long=[longitude]

Then in your Map page code, you can simply have the JavaScript that runs on that page grab the information from the URL (either using native JavaScript as described in this SO post, or using a third party library such as jQuery). Then you can center the map.

Community
  • 1
  • 1
Matthew Herbst
  • 29,477
  • 23
  • 85
  • 128